Download the PHP package overtrue/yaf-skeleton without Composer
On this page you can find all versions of the php package overtrue/yaf-skeleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yaf-skeleton
Yaf skeleton
The Yaf testable skeleton and composer supported.
Requirement
- PHP >= 7.0
- Yaf >= 3.0
Installation
-
Update
yaf.ini
: -
Create project.
-
Web server rewrite rules:
Apache
Nginx
Lighttpd
Application structor
Controllers
All controllers are created in the app/controllers
directory,and test files are also created in the tests/controllers
directorty.
Of course, you can also create tests independently:
The handle() method
The controller entry method handle()
:
Views
There is no built-in template engine. If you need to use a PHP template, we recommend that you use Plates, Plates is a native PHP template system that's fast, easy to use and easy to extend.
You can use view(string $template, array $data)
helper in controller handle
method as a result.
for example:
More usage please read the Plates Docs.
Unit tests
The difficulty of writing unit tests is inversely proportional to the quality of your code. The higher the code quality, the lower the difficulty of unit testing, so design your code well.
The unit test for creating the controller can be done with the following command:
Write test cases
To create a controller test object, use,you can use the mock_controller
function:
Assertion
We have such a controller:
So the test should cover the above three behaviors:
Facade Assertion
Built-in auxiliary assertion methods
They are used to correspond to exceptions thrown by abort($message, $code);
in the controller
Some helper methods in test case classes
Mock request method:
Mock request uri
:
Mock config:
Mock request IP:
Mock $_SERVER vars:
Docs
- Yaf Docs: http://www.php.net/manual/en/book.yaf.php
- Plates Docs: http://platesphp.com/v3/
- PHPUnit Docs: https://phpunit.de/manual/current/zh_cn/phpunit-book.html
- Mockery Docs: http://docs.mockery.io/en/latest/
:heart: Sponsor me
如果你喜欢我的项目并想支持它,点击这里 :heart:
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
PHP 扩展包开发
想知道如何从零开始构建 PHP 扩展包?
请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》
License
MIT
All versions of yaf-skeleton with dependencies
ext-yaf Version *
psr/http-message Version ~1.0
symfony/console Version 3.*
monolog/monolog Version ~1.0
psr/container Version ^1.0