1. Go to this page and download the library: Download xiangyu2038/flysky library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use XiangYu2038\FlySky\FlySKy;
$config = FlySKy::getContainer()->make('config') -> get('config.test');
// 路由配置文件
use Symfony\Component\Routing;
$routes = new Routing\RouteCollection();
$routes->add('test', new Routing\Route('/test/{hello}', array(
'year' => null,
'_controller' => 'App\Http\TestController::index',
)));
return $routes;
namespace App\Http;
use Symfony\Component\HttpFoundation\Request;
class TestController
{
public function index(Request $request)
{
return 'test';
}
}
///app/Events/test.php
namespace App\Events;
class Test
{
public $order;
/**
* 创建一个事件实例。
*
* @return void
*/
public function __construct()
{
}
}
///////app/Listeners/test.php
namespace App\Listeners;
class Test {
public function __construct()
{
//
}
public function handle($event)
{
//......各种实现
}
}
///////app/Providers/EventServiceProvider.php
namespace App\Providers;
use App\Events\Test;
use XiangYu2038\FlySky\Listeners\KernelView;
use XiangYu2038\FlySky\providers\EventServiceProvider as EventService;
use XiangYu2038\FlySky\Listeners\KernelException;
use XiangYu2038\FlySky\Listeners\KernelRequest;
use XiangYu2038\FlySky\Listeners\KernelFinishRequest;
class EventServiceProvider extends EventService
{
protected $dispatcher;///
/**
* 事件监听
*
* @var array
*/
protected $listen = [
'kernel.request' => [
KernelRequest::class,
],
'kernel.finish_request' => [
KernelFinishRequest::class,
],
'kernel.exception' => [
KernelException::class,
],
'kernel.view' => [
KernelView::class,
],
Test::class => [
\App\Listeners\Test::class
]
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
}
public function register(){
parent::register();
}
}
///////app/Exceptions/Exceptions.php
namespace App\Exceptions;
use Symfony\Component\Debug\Exception\FlattenException;
class Exception {
public function __construct()
{
//
}
public function handle(FlattenException $exception)
{
dd($exception);
//......各种实现
}
}