我使用Slim Framework作为路由器,Twig作为模板引擎和Eloquent ORM来处理数据库.
我为这些库创建了引导程序.
<?php
require_once 'vendor/autoload.php';
/**
* Laravel Eloquent ORM
*/
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$database_capsule = new Capsule;
$database_capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
$database_capsule->setEventDispatcher(new Dispatcher(new Container));
$database_capsule->setAsGlobal();
$database_capsule->bootEloquent();
/**
* Twig Template Engine
*/
Twig_Autoloader::register();
$twig_loader = new Twig_Loader_Filesystem('template');
$twig_engine = new Twig_Environment($twig_loader);
Run Code Online (Sandbox Code Playgroud)
路线:
/**
* Slim Framework
*/
$application = new …Run Code Online (Sandbox Code Playgroud) 有一次,我在一次讲座中听到?>用来关闭PHP文件导致性能下降,这是真的吗?
有趣的是,许多php应用程序和框架确实没有关闭文件?>.可能是样板还是性能?
代码中的空格会影响应用程序的性能吗?