catpaw/core
Composer 安装命令:
composer require catpaw/core
包简介
CatPaw core
README 文档
README
Catpaw is an opinionated group of libraries centered around catpaw/core, which is a dependency injection library built for amphp that makes heavy use of php attributes.
Table of Contents
| Topic | Implemented | Repository | Read |
|---|---|---|---|
| 🌐 Web Route Handlers | ✅ | catpaw-web | Read |
| 🌐 Web Route Controllers | ✅ | catpaw-web | Read |
| 🌐 Web Path Parameters | ✅ | catpaw-web | Read |
| 🌐 Web Path Not Found | ✅ | catpaw-web | Read |
| 🌐 Web Session | ✅ | catpaw-web | Read |
| 🌐 Open API | ✅ | catpaw-web | Read |
| 🌐 File System Web Routes | ✅ | catpaw-web | Read |
| ⚡ Entry | ✅ | catpaw-core | Read |
| 🌐 Web Byte Range Requests | ✅ | catpaw-web | Read |
| ⚡ Custom Attributes | ✅ | catpaw-core | Read |
| 🌐 Web Filters | ✅ | catpaw-web | Read |
| 🌐 Web Sockets | ✅ | catpaw-web | Read |
| 💡 RaspberryPI | ✅ | catpaw-raspberrypi | Read |
| ⚡ Services | ✅ | catpaw-core | Read |
| 🗄 MySQL Repositories | ✅ | catpaw-mysql | TODO |
| ⚡ Stores | ✅ | catpaw-store | Read |
| ⚡ Dev Tools Binary | ✅ Download | catpaw-dev-tools | Read |
| ⚡ Queues | ✅ | catpaw-queue | Read |
| 💡 Text | ✅ | catpaw-text | TODO |
| 💡 Schedule | ✅ | catpaw-schedule | TODO |
| 💡 SDL | ✅ | catpaw-libsdl | Read |
Starters
| Type | Implemented | Description | Github Template | Read |
|---|---|---|---|---|
| Blank | ✅ | using only the core library | Template | Read |
| Web | ✅ | create a web server | Template | Read |
| Markdown | ✅ | create a web server using Markdown | Template | TODO |
Note use with composer
composer create-project catpaw/startercomposer create-project catpaw/web-startercomposer create-project catpaw/markdown-starter
Premise
This project is aimed at linux distributions, some features may or not may work on Windows or MacOS.
Feel free to contribute fixing issues for specific platforms.
Get started
In order to get started you will need php 8.1 or a more recent version.
All you need to do is create a new project using the starter template.
composer create-project catpaw/starter
Or you could also clone the template from https://github.com/tncrazvan/catpaw-starter
Every application must declare a main function in the global scope, that will be your entry point:
<?php // src/main.php function main(){ echo "hello world\n"; }
After you've created your new project, you can run it using
composer watch
to watch file changes (useful in development) or
composer start
for production mode.
Build & Run
It is possible, but not required, to build your application into a single .phar file using
composer build
The building process can be configured inside the build.yml file.
After building your application, you can simply run it using
php dist/app.phar
The resulting .phar, by default (check build.yml), includes the following directories:
./src./vendor./resources./bin./.build-cache(created at comptile time)
which means it's a portable binary, you just need to make sure php is installed on whatever machine you're trying to run it on.
A note on versioning
Given the versioning string major.minor.patch, all libraries that are compatible with eachother will always have the same major and minor versions.
Regardless if a library has actually had any major or minor changes, its version will be bumped to match all the other libraries to indicate that given library is compatible with the latest features.
The patch number may vary from library to library, but the major and minor numbers should all match.
For example, if you're using catpaw/core:^0.2 and you want to add catpaw/web to your project, you should always pick catpaw/web:^0.2 to match your core version.
Why?
I'm a single developer and this gives me more freedom to add features without breaking previous versions and I like to organize my projects this way.
Looking for some examples?
You can follow along with the examples provided by the catpaw/examples repository at https://github.com/tncrazvan/catpaw-examples/tree/master/src.
Debugging with VSCode
In order to debug with vscode you will need to configure both vscode and xdebug (3.x).
XDebug 3.x configuration for VSCode
In your php.ini file add:
[xdebug] xdebug.client_host=127.0.0.1 xdebug.client_port=9003
VSCode configuration
Make new a ./.vscode/launch.json file in your project and add the following configuration if you don't have it already:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen (paw)",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "main (paw)",
"type": "php",
"request": "launch",
"program": "${workspaceFolder}/bin/start",
"cwd": "${workspaceFolder}",
"args": [
"--libraries='./src/lib/'",
"--entry='./src/main.php'"
],
"runtimeArgs": [
"-dxdebug.start_with_request=yes",
"-dxdebug.mode=debug"
],
"env": {
"XDEBUG_MODE": "debug",
"XDEBUG_CONFIG": "client_port=${port}"
}
}
]
}
The first configuration will passively listen for xdebug, while the second one will launch the currently opened script.
catpaw/core 适用场景与选型建议
catpaw/core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.8k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 01 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「http」 「websocket」 「cli」 「server」 「catpaw」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 catpaw/core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 catpaw/core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 catpaw/core 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
http客户端
WebSocket view engine
Easily add Excepct-CT header to your project
Build mini web servers in PHP for testing
Alfabank REST API integration
统计信息
- 总下载量: 4.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-02