本文整理汇总了PHP中Phalcon\Loader::setExtensions方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::setExtensions方法的具体用法?PHP Loader::setExtensions怎么用?PHP Loader::setExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Loader
的用法示例。
在下文中一共展示了Loader::setExtensions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
<?php
use Phalcon\Loader, Phalcon\Mvc\Model, Phalcon\Mvc\Url, Phalcon\Crypt, Phalcon\Mvc\View\Engine\Volt, Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter, Phalcon\Logger\Multiple as MultipleStreamLogger, Phalcon\Logger\Adapter\File as FileLogger, Phalcon\Logger\Adapter\Firephp as FirephpLogger, Webird\Module, Webird\Mvc\View\Simple as ViewSimple, Webird\Acl\Acl, Webird\DatabaseSessionReader, Webird\Locale\Locale, Webird\Locale\Gettext, Webird\Mailer\Manager as MailManager, Webird\Logger\Adapter\Error as ErrorLogger, Webird\Logger\Adapter\Firelogger;
/**
*
*/
Model::setup(['phqlLiterals' => false, 'notNullValidations' => false]);
/**
*
*/
$di->set('loader', function () use($config) {
$commonDir = $config->path->commonDir;
$modulesDir = $config->path->modulesDir;
$loader = new Loader();
$loader->setExtensions(['php']);
$loader->registerNamespaces(['Webird\\Models' => "{$commonDir}/models", 'Webird\\Forms' => "{$commonDir}/forms", 'Webird\\Plugins' => "{$commonDir}/plugins", 'Webird' => "{$commonDir}/library"]);
$loader->register();
$classes = [];
foreach ($config->app->modules as $moduleName) {
$class = 'Webird\\' . ucfirst($moduleName) . '\\Module';
$path = Module::moduleNameToDir($moduleName) . 'Module.php';
$classes[$class] = $path;
}
$loader->registerClasses($classes, true);
$loader->register();
return $loader;
});
$di->get('loader');
/**
*
*/
示例2: Loader
<?php
use Phalcon\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\Mvc\Micro\Collection as MicroCollection;
use Phalcon\Di\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql;
// Use Loader() to autoload our model
$loader = new Loader();
$loader->registerDirs(array('models', 'controllers'))->register();
$loader->setExtensions(array("php", "inc", "phb"));
$di = new FactoryDefault();
// Set up the database service
$di->set('db', function () {
return new PdoMysql(array("host" => "localhost", "username" => "root", "password" => "", "dbname" => "oversign"));
});
$app = new Micro($di);
$users = new MicroCollection();
$users->setHandler("UserController", true);
$users->setPrefix('/user');
$users->get('/', 'hello');
$app->mount($users);
// Retrieves all robots
$app->get('/api/robots', function () {
$phql = "SELECT * FROM Robots ORDER BY name";
$robots = $app->modelsManager->executeQuery($phql);
$data = array();
foreach ($robots as $robot) {
$data[] = array('id' => $robot->id, 'name' => $robot->name);
}
echo json_encode($data);
示例3: Loader
<?php
use Phalcon\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\Di\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql;
use Phalcon\Http\Response;
// use Loader() to autoload our model
$loader = new Loader();
$loader->setExtensions(array("php"));
$loader->registerDirs(array(__DIR__ . '/models/'))->register();
// set up the database service
$di = new FactoryDefault();
//----------------------------
//DATABASE CONFIG
//----------------------------
$di->set('db', function () {
return new PdoMysql(array("host" => "localhost", "port" => "", "username" => "root", "password" => "faraz", "dbname" => "products"));
});
//table name in schema is Products, if change is made to this table name then
//API method handlers should be updated
// bind the DI to the application
$app = new Micro($di);
// API -------------------------------------------
// Products is the table name in MySQL database
// Retrieves all products
$app->get('/api/products', function () use($app) {
$phql = "SELECT * FROM Products ORDER BY name";
//Products is table name
$products = $app->modelsManager->executeQuery($phql);
$data = array();
示例4: setExtensions
public function setExtensions(array $extensions)
{
return parent::setExtensions($extensions);
}