phalcon appfactory
1.0.0
Application skeleton for Phalcon CLI and Micro and API application. You can override the service and DI (and routes) configuration and just use your simple preconfigured application.
composer config repositories.phalcon-appfactory vcs https://github.com/dzooli/phalcon-appfactory.git
composer require -o -vv dzooli/phalcon-appfactory:dev-masterCreate your customized application factory:
<?php
namespace App;
use DzooliPhalconCoreAbstractAppFactory;
use DzooliPhalconCoreMicroAppFactory;
use DzooliPhalconCoreRouterDefinitionInterface;
class MyAppFactory extends MicroAppFactory implements RouterDefinitionInterface
{
public function addRoutes(): AbstractAppFactory
{
$app = $this->app;
$this->app->get('/', function () use ($app) {
echo $app['view']->render('index');
});
return $this;
}
}And use it in your main program (such as index.php):
<?php
use AppMyAppFactory; /* This is your overrided Application Factory definition. */
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
require_once(BASE_PATH . '/vendor/autoload.php');
try {
$appFactory = new MyAppFactory(APP_PATH);
$appFactory->createApp()
->addRoutes()
->getApp()
->handle($_SERVER['REQUEST_URI']);
} catch (Exception $e) {
echo $e->getMessage() . '<br>';
echo '<pre>' . $e->getTraceAsString() . '</pre>';
}Pull requests are welcome on the develop branch.