microframe / app
一个简单的微框架,带有MVC风格,但无需模型
dev-master
2023-02-24 02:04 UTC
Requires
- php: >=7.3
- ext-curl: *
- ext-fileinfo: *
- ext-json: *
- ext-pdo: *
- ext-sqlite3: *
- asyncphp/doorman: 3.1.*
- cebe/markdown: 1.2.*
- hassankhan/config: 2.1.*
- phpfastcache/phpfastcache: 8.0.*
- predis/predis: 1.1.*
- symfony/finder: 5.1.*
- symfony/process: 5.1.*
- symfony/serializer: 3.4.*
- symfony/yaml: 5.1.*
- taq/pdooci: 1.0.*
- zircote/swagger-php: 3.0.*
Requires (Dev)
- filp/whoops: 2.7.*
- friendsofphp/php-cs-fixer: 2.16.*
- opsway/psr12-strict-coding-standard: 0.4.*
- phpunit/phpunit: 7.5.*
- squizlabs/php_codesniffer: 3.5.*
Suggests
- ext-apache: *
- ext-ftp: Required to use the Flysystem FTP driver.
- ext-gd: Required to use for...
- ext-memcached: Required to use the memcache cache driver.
- ext-pcntl: Required to use all features of the queue worker.
- ext-posix: Required to use all features of the queue worker.
- ext-redis: Required to use the Redis cache and queue drivers (^4.0|^5.0).
- mockery/mockery: Required to use mocking (^1.3.1).
This package is auto-updated.
Last update: 2024-09-24 21:29:27 UTC
README
composer create-project microframe/app testApp --no-dev
简单控制器使用
注意:对于微服务,必须在收到响应之前设置头部接受。
<?php use MicroFrame\Core\Controller as Core; class TestController extends Core { public function index() { $this->response ->data("Keeping it short...") ->send(); } }
更长的故事
<?php use MicroFrame\Core\Controller as Core; class TestController extends Core { public function index() { $this->auto(false); $this->response // Optional set method ->methods(['get', 'post']) // It's optional but why, I don't remember. ->data(['villains' => ['Black Beard', 'Douglass Bullet', 'D Rocks', 'Im Sama']]) // Set optional formats application/json | application/xml no etc for now. ->format("application/xml") // Hmm, yeah optional middleware, nothing magical I guess if they all return true. ->middleware(['default', 'companyA.easyAuth', 'customApp.validation']) // Set session stuffs for only this response ->session("key", "value") // Optional redirection ->redirect("index") // Optional time response refresh in seconds. ->refresh(60, "index") // Optional status stuff ->status(200) // Required. ->send(); } }
为什么要使用MicroFrame
我知道这个名字不够创意,有点糟糕,嗯,也不是一个好笑的玩笑,因为这个玩笑需要解释才能简短:一个简单的微框架,带有MVC风格的少许接触。
如果你觉得代码中存在任何缺陷或需要改进的地方,请告诉我,也请教我任何东西。
如果你还没有理解q[M]VC,它是在一个花哨的文件/类中的查询和参数,但我相信你不会太讨厌它,它确实有效,其他我想应该是正常的东西,也许除了任务、路由以及其他你注意到的东西,希望它们在你使用时都能正常工作。
注意:我现在还不敢想这个可以取代你的laravel、fuelPhp或codeIgniter4,因为我特别喜欢这些PHP框架,特别是codeIgniter4,但MicroFrame存在是为了不同的目的。
- 首先让我不那么无聊
- 其次,我可以在东西上写我的名字,试试看,“感觉真好”。
- 严肃的理由 -> 做很多事情超级快,除了模型[不是每个人都需要模型,我知道很多旧系统],再次需要迭代,简单任务,简单异步,缓存,自动渲染openAPI V3标签,基于标签的自动代码文档,自定义/外部代码路由等。