From c87ccd811dfa37da804deffce7fe294eb4c46e29 Mon Sep 17 00:00:00 2001 From: s-ohnishi Date: Fri, 14 Jul 2023 17:38:48 +0900 Subject: [PATCH] adapted to v5 namespaces, methods reflect namespace and method name changes the part that uses the database of Invo matches the setting of Invo --- hmvc/public/index.php | 8 ++--- micro-factory-default/config/config.php | 2 +- micro-factory-default/public/index.php | 6 ++-- micro-simple-views/config/config.php | 2 +- micro-simple-views/config/services.php | 16 ++++++--- micro-simple-views/index.php | 2 +- micro-simple-views/views/500.volt | 2 +- micro-simple-views/views/index.volt | 2 +- micro/index.php | 2 +- .../apps/frontend/Module.php | 6 ++-- .../apps/frontend/config/config.php | 2 +- multiple-factory-default/public/index.php | 6 ++-- .../apps/config/config.php | 8 ++--- .../apps/config/services.php | 12 ++++--- .../apps/models/entities/User.php | 8 ++--- .../apps/modules/frontend/Module.php | 6 ++-- .../modules/frontend/views/index/index.phtml | 1 + multiple-service-layer-model/public/index.php | 6 ++-- .../apps/backend/Module.php | 6 ++-- .../apps/backend/config/config.php | 2 +- .../apps/frontend/Module.php | 6 ++-- .../apps/frontend/config/config.php | 2 +- multiple-shared-layouts/public/index.php | 6 ++-- .../apps/modules/backend/Module.php | 14 ++++---- .../apps/modules/frontend/Module.php | 14 ++++---- multiple-shared-views/public/index.php | 2 +- multiple-volt/apps/frontend/Module.php | 6 ++-- multiple-volt/apps/frontend/config/config.php | 2 +- multiple-volt/config/services.php | 9 +++-- multiple-volt/public/index.php | 2 +- multiple/apps/backend/Module.php | 14 ++++---- multiple/apps/frontend/Module.php | 14 ++++---- multiple/public/index.php | 6 ++-- simple-subcontrollers/app/config/config.php | 2 +- simple-subcontrollers/app/config/loader.php | 4 +-- simple-subcontrollers/app/config/services.php | 23 ++++++++----- .../app/views/admin/users/index.volt | 5 ++- simple-subcontrollers/app/views/index.volt | 2 +- .../app/views/users/index.volt | 5 ++- simple-subcontrollers/public/index.php | 2 +- simple-volt/app/config/config.php | 2 +- simple-volt/app/config/loader.php | 4 +-- simple-volt/app/config/services.php | 34 +++++++++++++------ simple-volt/public/index.php | 6 ++-- simple-without-application/public/index.php | 17 +++++----- simple/public/index.php | 23 ++++++++----- single-camelized-dirs/app/Config/Loader.php | 9 +++-- single-camelized-dirs/app/Config/Services.php | 10 +++--- .../app/Views/Index/Index.phtml | 2 +- single-camelized-dirs/public/index.php | 14 ++++---- single-factory-default/app/config/config.php | 2 +- single-factory-default/public/index.php | 19 +++++++---- single-namespaces/public/index.php | 16 ++++----- single-service-provider/app/Bootstrap.php | 8 ++--- .../app/Providers/AbstractServiceProvider.php | 6 ++-- .../app/Providers/ConfigServiceProvider.php | 5 ++- .../app/Providers/DatabaseServiceProvider.php | 2 +- .../app/Providers/EscaperServiceProvider.php | 2 +- .../PhpTemplateEngineServiceProvider.php | 2 +- .../app/Providers/RouterServiceProvider.php | 2 +- .../app/Providers/SessionServiceProvider.php | 12 +++++-- .../app/Providers/TagServiceProvider.php | 17 +++++++++- .../Providers/UrlResolverServiceProvider.php | 2 +- .../app/Providers/ViewServiceProvider.php | 2 +- .../VoltTemplateEngineServiceProvider.php | 8 ++--- .../bootstrap/autoload.php | 4 +-- single/public/index.php | 23 ++++++++----- 67 files changed, 289 insertions(+), 209 deletions(-) diff --git a/hmvc/public/index.php b/hmvc/public/index.php index a7c088b..c0c1d08 100644 --- a/hmvc/public/index.php +++ b/hmvc/public/index.php @@ -1,7 +1,7 @@ registerDirs( + $loader->setDirectories( [ "../app/controllers/", ] @@ -100,6 +100,6 @@ public function request(array $location, $data = null) -$response = $app->handle(); +$response = $app->handle($_SERVER["REQUEST_URI"]); $response->send(); diff --git a/micro-factory-default/config/config.php b/micro-factory-default/config/config.php index dd799d6..44e3997 100644 --- a/micro-factory-default/config/config.php +++ b/micro-factory-default/config/config.php @@ -1,6 +1,6 @@ registerDirs([$config->application->modelsDir]) + ->setDirectories([$config->application->modelsDir]) ->register(); /** @@ -72,7 +72,7 @@ /** * Handle the request */ - $app->handle(); + $app->handle($_SERVER["REQUEST_URI"]); } catch (\Exception $e) { echo $e->getMessage(), PHP_EOL; echo $e->getTraceAsString(); diff --git a/micro-simple-views/config/config.php b/micro-simple-views/config/config.php index 17e06c1..ec8e1ed 100644 --- a/micro-simple-views/config/config.php +++ b/micro-simple-views/config/config.php @@ -1,6 +1,6 @@ registerEngines( [ - '.volt' => function ($view, $di) use ($config) { - $volt = new VoltEngine($view, $di); + '.volt' => function ($view) use ($config) { + $volt = new VoltEngine($view); $volt->setOptions( [ - 'compiledPath' => $config->application->cacheDir, - 'compiledSeparator' => '_', + 'path' => $config->application->cacheDir, + 'separator' => '_', ] ); @@ -47,3 +47,11 @@ return $view; }); + + +$di->setShared( + 'tag', + function () { + return new \Phalcon\Html\TagFactory(new \Phalcon\Html\Escaper()); + } +); diff --git a/micro-simple-views/index.php b/micro-simple-views/index.php index ce63796..a024c60 100644 --- a/micro-simple-views/index.php +++ b/micro-simple-views/index.php @@ -20,4 +20,4 @@ echo $app['view']->render('500'); }); -$app->handle(); +$app->handle($_SERVER["REQUEST_URI"]); diff --git a/micro-simple-views/views/500.volt b/micro-simple-views/views/500.volt index 0198125..b4b629a 100644 --- a/micro-simple-views/views/500.volt +++ b/micro-simple-views/views/500.volt @@ -1,3 +1,3 @@

500 Error

-tag->linkTo('index', 'Go Home') ?> +tag->a('index', 'Go Home') ?> diff --git a/micro-simple-views/views/index.volt b/micro-simple-views/views/index.volt index bb06e5e..a674413 100644 --- a/micro-simple-views/views/index.volt +++ b/micro-simple-views/views/index.volt @@ -1,3 +1,3 @@

Welcome

-tag->linkTo('', 'Go Home') ?> +tag->a('index', 'Go Home') ?> diff --git a/micro/index.php b/micro/index.php index b110b98..27c374d 100644 --- a/micro/index.php +++ b/micro/index.php @@ -39,4 +39,4 @@ function () use ($app) { } ); -$app->handle(); +$app->handle($_SERVER["REQUEST_URI"]); diff --git a/multiple-factory-default/apps/frontend/Module.php b/multiple-factory-default/apps/frontend/Module.php index 37a56c4..adb4e14 100644 --- a/multiple-factory-default/apps/frontend/Module.php +++ b/multiple-factory-default/apps/frontend/Module.php @@ -2,9 +2,9 @@ namespace Modules\Frontend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\ModuleDefinitionInterface; use Phalcon\Db\Adapter\Pdo\Mysql as MySQLAdapter; @@ -20,7 +20,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Modules\Frontend\Controllers' => __DIR__ . '/controllers/', 'Modules\Frontend\Models' => __DIR__ . '/models/', diff --git a/multiple-factory-default/apps/frontend/config/config.php b/multiple-factory-default/apps/frontend/config/config.php index 5d614e9..cdba16a 100644 --- a/multiple-factory-default/apps/frontend/config/config.php +++ b/multiple-factory-default/apps/frontend/config/config.php @@ -1,6 +1,6 @@ handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); -} catch (Phalcon\Exception $e) { - echo $e->getMessage(); } catch (PDOException $e) { echo $e->getMessage(); +} catch (Exception $e) { + echo $e->getMessage(); } diff --git a/multiple-service-layer-model/apps/config/config.php b/multiple-service-layer-model/apps/config/config.php index e28fc2d..ee7eb4d 100644 --- a/multiple-service-layer-model/apps/config/config.php +++ b/multiple-service-layer-model/apps/config/config.php @@ -1,15 +1,15 @@ [ 'adapter' => 'Mysql', 'host' => 'localhost', - 'username' => 'root', - 'password' => '', - 'dbname' => 'phalcon', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ], 'application' => [ 'controllersDir' => __DIR__ . '/../controllers/', diff --git a/multiple-service-layer-model/apps/config/services.php b/multiple-service-layer-model/apps/config/services.php index 2368cad..1f51c4e 100644 --- a/multiple-service-layer-model/apps/config/services.php +++ b/multiple-service-layer-model/apps/config/services.php @@ -6,7 +6,8 @@ use Phalcon\Mvc\Router; use Phalcon\Mvc\Url as UrlResolver; use Phalcon\DI\FactoryDefault; -use Phalcon\Session\Adapter\Files as SessionAdapter; +use Phalcon\Session\Adapter\Stream as SessionFiles; +use Phalcon\Session\Manager as SessionManager; /** * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework @@ -23,8 +24,6 @@ $router->setDefaultModule("frontend"); $router->setDefaultNamespace("Modules\Modules\Frontend\Controllers"); - $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI); - $router->removeExtraSlashes(true); return $router; @@ -44,7 +43,12 @@ * Start the session the first time some component request the session service */ $di['session'] = function () { - $session = new SessionAdapter(); + $session = new SessionManager(); + $files = new SessionFiles([ + 'savePath' => sys_get_temp_dir(), + ]); + + $session->setAdapter($files); $session->start(); return $session; diff --git a/multiple-service-layer-model/apps/models/entities/User.php b/multiple-service-layer-model/apps/models/entities/User.php index bc7209d..8d22db3 100644 --- a/multiple-service-layer-model/apps/models/entities/User.php +++ b/multiple-service-layer-model/apps/models/entities/User.php @@ -3,8 +3,8 @@ namespace Modules\Models\Entities; use Phalcon\Mvc\Model; -use Phalcon\Validation; -use Phalcon\Validation\Validator\Email as EmailValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\Email as EmailValidator; class User extends Model { @@ -200,8 +200,4 @@ public function validation() return $this->validate($validator); } - public function getSource() - { - return 'user'; - } } diff --git a/multiple-service-layer-model/apps/modules/frontend/Module.php b/multiple-service-layer-model/apps/modules/frontend/Module.php index c7dfc07..5cf77e9 100644 --- a/multiple-service-layer-model/apps/modules/frontend/Module.php +++ b/multiple-service-layer-model/apps/modules/frontend/Module.php @@ -2,9 +2,9 @@ namespace Modules\Modules\Frontend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\ModuleDefinitionInterface; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; @@ -19,7 +19,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Modules\Modules\Frontend\Controllers' => __DIR__ . '/controllers/', 'Modules\Models\Entities' => __DIR__ . '/../../models/entities/', diff --git a/multiple-service-layer-model/apps/modules/frontend/views/index/index.phtml b/multiple-service-layer-model/apps/modules/frontend/views/index/index.phtml index e69de29..899d525 100644 --- a/multiple-service-layer-model/apps/modules/frontend/views/index/index.phtml +++ b/multiple-service-layer-model/apps/modules/frontend/views/index/index.phtml @@ -0,0 +1 @@ +getName(); ?> \ No newline at end of file diff --git a/multiple-service-layer-model/public/index.php b/multiple-service-layer-model/public/index.php index 28a0ab5..34c55c2 100644 --- a/multiple-service-layer-model/public/index.php +++ b/multiple-service-layer-model/public/index.php @@ -27,11 +27,11 @@ */ require __DIR__ . '/../apps/config/modules.php'; - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); -} catch (Phalcon\Exception $e) { - echo $e->getMessage(); } catch (PDOException $e) { echo $e->getMessage(); +} catch (Exception $e) { + echo $e->getMessage(); } diff --git a/multiple-shared-layouts/apps/backend/Module.php b/multiple-shared-layouts/apps/backend/Module.php index 1568e14..fd83184 100644 --- a/multiple-shared-layouts/apps/backend/Module.php +++ b/multiple-shared-layouts/apps/backend/Module.php @@ -2,9 +2,9 @@ namespace Modules\Backend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\ModuleDefinitionInterface; use Phalcon\Db\Adapter\Pdo\Mysql as MySQLAdapter; @@ -20,7 +20,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Modules\Backend\Controllers' => __DIR__ . '/controllers/', 'Modules\Backend\Models' => __DIR__ . '/models/', diff --git a/multiple-shared-layouts/apps/backend/config/config.php b/multiple-shared-layouts/apps/backend/config/config.php index 5d614e9..cdba16a 100644 --- a/multiple-shared-layouts/apps/backend/config/config.php +++ b/multiple-shared-layouts/apps/backend/config/config.php @@ -1,6 +1,6 @@ registerNamespaces( + $loader->setNamespaces( [ 'Modules\Frontend\Controllers' => __DIR__ . '/controllers/', 'Modules\Frontend\Models' => __DIR__ . '/models/', diff --git a/multiple-shared-layouts/apps/frontend/config/config.php b/multiple-shared-layouts/apps/frontend/config/config.php index 5d614e9..cdba16a 100644 --- a/multiple-shared-layouts/apps/frontend/config/config.php +++ b/multiple-shared-layouts/apps/frontend/config/config.php @@ -1,6 +1,6 @@ handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); -} catch (Phalcon\Exception $e) { - echo $e->getMessage(); } catch (PDOException $e) { echo $e->getMessage(); +} catch (Exception $e) { + echo $e->getMessage(); } diff --git a/multiple-shared-views/apps/modules/backend/Module.php b/multiple-shared-views/apps/modules/backend/Module.php index 939b98b..d1cce9f 100644 --- a/multiple-shared-views/apps/modules/backend/Module.php +++ b/multiple-shared-views/apps/modules/backend/Module.php @@ -2,8 +2,8 @@ namespace Multiple\Backend; -use Phalcon\Loader; -use Phalcon\DiInterface; +use Phalcon\Autoload\Loader; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Dispatcher; use Phalcon\Db\Adapter\Pdo\Mysql; use Phalcon\Mvc\ModuleDefinitionInterface; @@ -19,7 +19,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ "Multiple\\Backend\\Controllers" => "../apps/modules/backend/controllers/", "Multiple\\Backend\\Models" => "../apps/modules/backend/models/", @@ -54,10 +54,10 @@ function () { function () { return new Mysql( [ - "host" => "localhost", - "username" => "root", - "password" => "secret", - "dbname" => "invo", + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); } diff --git a/multiple-shared-views/apps/modules/frontend/Module.php b/multiple-shared-views/apps/modules/frontend/Module.php index 23a4fb2..779bbb7 100644 --- a/multiple-shared-views/apps/modules/frontend/Module.php +++ b/multiple-shared-views/apps/modules/frontend/Module.php @@ -2,8 +2,8 @@ namespace Multiple\Frontend; -use Phalcon\Loader; -use Phalcon\DiInterface; +use Phalcon\Autoload\Loader; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Dispatcher; use Phalcon\Db\Adapter\Pdo\Mysql; use Phalcon\Mvc\ModuleDefinitionInterface; @@ -19,7 +19,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ "Multiple\\Frontend\\Controllers" => "../apps/modules/frontend/controllers/", "Multiple\\Frontend\\Models" => "../apps/modules/frontend/models/", @@ -53,10 +53,10 @@ function () { function () { return new Mysql( [ - "host" => "localhost", - "username" => "root", - "password" => "secret", - "dbname" => "invo", + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); } diff --git a/multiple-shared-views/public/index.php b/multiple-shared-views/public/index.php index dd08987..7ce5dfa 100644 --- a/multiple-shared-views/public/index.php +++ b/multiple-shared-views/public/index.php @@ -87,6 +87,6 @@ function () { ] ); -$response = $application->handle(); +$response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); diff --git a/multiple-volt/apps/frontend/Module.php b/multiple-volt/apps/frontend/Module.php index 8dc2810..8827dd1 100644 --- a/multiple-volt/apps/frontend/Module.php +++ b/multiple-volt/apps/frontend/Module.php @@ -2,9 +2,9 @@ namespace Multiple\Frontend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\ModuleDefinitionInterface; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\View\Engine\Volt as VoltEngine; @@ -20,7 +20,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Multiple\Frontend\Controllers' => __DIR__ . "/controllers/", 'Multiple\Frontend\Models' => __DIR__ . "/models/", diff --git a/multiple-volt/apps/frontend/config/config.php b/multiple-volt/apps/frontend/config/config.php index b4117ae..0cd14d4 100644 --- a/multiple-volt/apps/frontend/config/config.php +++ b/multiple-volt/apps/frontend/config/config.php @@ -1,6 +1,6 @@ sys_get_temp_dir(), + ]); + $session->setAdapter($files); $session->start(); return $session; diff --git a/multiple-volt/public/index.php b/multiple-volt/public/index.php index 2c87895..9f675f5 100644 --- a/multiple-volt/public/index.php +++ b/multiple-volt/public/index.php @@ -25,7 +25,7 @@ */ require __DIR__ . "/../config/modules.php"; - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); } catch (Exception $e) { diff --git a/multiple/apps/backend/Module.php b/multiple/apps/backend/Module.php index 1329221..bbc8203 100644 --- a/multiple/apps/backend/Module.php +++ b/multiple/apps/backend/Module.php @@ -2,10 +2,10 @@ namespace Multiple\Backend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; use Phalcon\Mvc\Dispatcher; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\ModuleDefinitionInterface; use Phalcon\Db\Adapter\Pdo\Mysql as Database; @@ -20,7 +20,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Multiple\Backend\Controllers' => '../apps/backend/controllers/', 'Multiple\Backend\Models' => '../apps/backend/models/', @@ -56,10 +56,10 @@ public function registerServices(DiInterface $di) $di->set('db', function () { return new Database( [ - "host" => "localhost", - "username" => "root", - "password" => "secret", - "dbname" => "invo" + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); }); diff --git a/multiple/apps/frontend/Module.php b/multiple/apps/frontend/Module.php index 33b195e..663a01d 100644 --- a/multiple/apps/frontend/Module.php +++ b/multiple/apps/frontend/Module.php @@ -2,9 +2,9 @@ namespace Multiple\Frontend; -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Events\Manager; use Phalcon\Mvc\Dispatcher; use Phalcon\Db\Adapter\Pdo\Mysql; @@ -21,7 +21,7 @@ public function registerAutoloaders(DiInterface $di = null) { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Multiple\Frontend\Controllers' => '../apps/frontend/controllers/', 'Multiple\Frontend\Models' => '../apps/frontend/models/', @@ -63,10 +63,10 @@ public function registerServices(DiInterface $di) $di->set('db', function () { return new Mysql( [ - "host" => "localhost", - "username" => "root", - "password" => "secret", - "dbname" => "invo" + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); }); diff --git a/multiple/public/index.php b/multiple/public/index.php index e7b578b..63ef1f1 100644 --- a/multiple/public/index.php +++ b/multiple/public/index.php @@ -2,7 +2,7 @@ error_reporting(E_ALL); -use Phalcon\Loader; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\Router; use Phalcon\DI\FactoryDefault; use Phalcon\Mvc\Application as BaseApplication; @@ -23,7 +23,7 @@ protected function registerServices() * We're a registering a set of directories taken from the configuration file */ $loader - ->registerDirs([__DIR__ . '/../apps/library/']) + ->setDirectories([__DIR__ . '/../apps/library/']) ->register(); // Registering a router @@ -80,7 +80,7 @@ public function main() ] ]); - $response = $this->handle(); + $response = $this->handle($_SERVER["REQUEST_URI"]); $response->send(); } diff --git a/simple-subcontrollers/app/config/config.php b/simple-subcontrollers/app/config/config.php index d2d2d54..69530f4 100644 --- a/simple-subcontrollers/app/config/config.php +++ b/simple-subcontrollers/app/config/config.php @@ -1,6 +1,6 @@ registerNamespaces( + ->setNamespaces( [ 'MyApp\Controllers' => __DIR__ . '/../controllers/', 'MyApp\Controllers\Admin' => __DIR__ . '/../controllers/admin' diff --git a/simple-subcontrollers/app/config/services.php b/simple-subcontrollers/app/config/services.php index 3781874..166b385 100644 --- a/simple-subcontrollers/app/config/services.php +++ b/simple-subcontrollers/app/config/services.php @@ -7,7 +7,8 @@ use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use Phalcon\Mvc\View\Engine\Volt as VoltEngine; use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter; -use Phalcon\Session\Adapter\Files as SessionAdapter; +use Phalcon\Session\Adapter\Stream as SessionFiles; +use Phalcon\Session\Manager as SessionManager; /** * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework @@ -39,13 +40,12 @@ $view->registerEngines( [ - '.volt' => function ($view, $di) use ($config) { - $volt = new VoltEngine($view, $di); - + '.volt' => function ($view) use ($config) { + $volt = new VoltEngine($view, $this); $volt->setOptions( [ - 'compiledPath' => $config->application->cacheDir, - 'compiledSeparator' => '_' + 'path' => $config->application->cacheDir, + 'separator' => '_' ] ); @@ -84,9 +84,14 @@ * Start the session the first time some component request the session service */ $di->set('session', function () { - $session = new SessionAdapter(); - $session->start(); - + $session = new SessionManager(); + $files = new SessionFiles([ + 'savePath' => '/tmp', + ]); + + $session + ->setAdapter($files) + ->start(); return $session; }); diff --git a/simple-subcontrollers/app/views/admin/users/index.volt b/simple-subcontrollers/app/views/admin/users/index.volt index 748373e..d828a64 100644 --- a/simple-subcontrollers/app/views/admin/users/index.volt +++ b/simple-subcontrollers/app/views/admin/users/index.volt @@ -1 +1,4 @@ -Users (admin) \ No newline at end of file +Users (admin) +
+{{ content() }} +
\ No newline at end of file diff --git a/simple-subcontrollers/app/views/index.volt b/simple-subcontrollers/app/views/index.volt index d4d50fe..c1eff94 100644 --- a/simple-subcontrollers/app/views/index.volt +++ b/simple-subcontrollers/app/views/index.volt @@ -1,5 +1,5 @@ - + Phalcon PHP Framework diff --git a/simple-subcontrollers/app/views/users/index.volt b/simple-subcontrollers/app/views/users/index.volt index ca37fce..69baa41 100644 --- a/simple-subcontrollers/app/views/users/index.volt +++ b/simple-subcontrollers/app/views/users/index.volt @@ -1 +1,4 @@ -Users (no admin) \ No newline at end of file +Users (no admin) +
+{{ content() }} +
\ No newline at end of file diff --git a/simple-subcontrollers/public/index.php b/simple-subcontrollers/public/index.php index c694ca6..1421b0b 100644 --- a/simple-subcontrollers/public/index.php +++ b/simple-subcontrollers/public/index.php @@ -26,7 +26,7 @@ */ $application = new Application($di); - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); } catch (\Exception $e) { diff --git a/simple-volt/app/config/config.php b/simple-volt/app/config/config.php index 8b8f964..91281b9 100644 --- a/simple-volt/app/config/config.php +++ b/simple-volt/app/config/config.php @@ -1,6 +1,6 @@ registerDirs( +$loader->setDirectories( [ $config->application->controllersDir, $config->application->modelsDir, diff --git a/simple-volt/app/config/services.php b/simple-volt/app/config/services.php index c9e6fb4..4ca73b4 100644 --- a/simple-volt/app/config/services.php +++ b/simple-volt/app/config/services.php @@ -1,13 +1,14 @@ registerEngines( [ - ".volt" => function ($view, $di) use ($config) { - $volt = new VoltEngine($view, $di); + ".volt" => function ($view) use ($config) { + $volt = new VoltEngine($view, $this); $volt->setOptions( [ - "compiledPath" => $config->application->cacheDir, - "compiledSeparator" => "_", + "path" => $config->application->cacheDir, + "separator" => "_", ] ); @@ -103,10 +104,23 @@ function () use ($config) { $di->set( "session", function () { - $session = new SessionAdapter(); + $session = new Session(); + $files = new SessionAdapter([ + 'savePath' => sys_get_temp_dir(), + ]); + $session->setAdapter($files); $session->start(); return $session; } ); + + +class myVoltEngine extends VoltEngine +{ + public function __set(string $key, $value) + { + } + +} \ No newline at end of file diff --git a/simple-volt/public/index.php b/simple-volt/public/index.php index 21dbe98..ffc3a71 100644 --- a/simple-volt/public/index.php +++ b/simple-volt/public/index.php @@ -25,11 +25,11 @@ $application = new \Phalcon\Mvc\Application(); $application->setDI($di); - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); -} catch (Phalcon\Exception $e) { - echo $e->getMessage(); } catch (PDOException $e) { echo $e->getMessage(); +} catch (Exception $e) { + echo $e->getMessage(); } diff --git a/simple-without-application/public/index.php b/simple-without-application/public/index.php index a8c2481..ce584a3 100644 --- a/simple-without-application/public/index.php +++ b/simple-without-application/public/index.php @@ -1,7 +1,7 @@ registerDirs( +$loader->setDirectories( [ '../apps/controllers/', '../apps/models/' @@ -40,10 +40,10 @@ $di->set('db', function () { return new Mysql([ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "invo" + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ]); }); @@ -55,7 +55,7 @@ try { $router = $di->getShared('router'); - $router->handle(); + $router->handle($_SERVER["REQUEST_URI"]); $view = $di->getShared('view'); @@ -83,4 +83,5 @@ $response->send(); } catch (\Exception $e) { echo $e->getMessage(); + var_dump(getcwd(), realpath('../apps/controllers/'), $loader->getDebug()); } diff --git a/simple/public/index.php b/simple/public/index.php index afb1838..ecde4c8 100644 --- a/simple/public/index.php +++ b/simple/public/index.php @@ -1,7 +1,7 @@ registerDirs( +$loader->setDirectories( [ "../apps/controllers/", "../apps/models/", @@ -58,10 +58,10 @@ function () { function () { return new Database( [ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "invo", + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); } @@ -73,10 +73,17 @@ function () { //Registering the Models Manager $di->set("modelsManager", ModelManager::class); +$di->setShared( + 'tag', + function () { + return new \Phalcon\Html\TagFactory(new \Phalcon\Html\Escaper()); + } +); + try { $application = new Application($di); - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); } catch (Exception $e) { diff --git a/single-camelized-dirs/app/Config/Loader.php b/single-camelized-dirs/app/Config/Loader.php index 9b78576..59dbc60 100644 --- a/single-camelized-dirs/app/Config/Loader.php +++ b/single-camelized-dirs/app/Config/Loader.php @@ -1,13 +1,12 @@ registerNamespaces( +$loader->setNamespaces( [ - 'Single\Controllers' => '../App/Controllers/', - 'Single\Models' => '../App/Models/' + 'Single\Controllers' => '../app/Controllers/', + 'Single\Models' => '../app/Models/' ] ); diff --git a/single-camelized-dirs/app/Config/Services.php b/single-camelized-dirs/app/Config/Services.php index 85662b5..ce6483c 100644 --- a/single-camelized-dirs/app/Config/Services.php +++ b/single-camelized-dirs/app/Config/Services.php @@ -19,7 +19,7 @@ // Registering the view component $di->setShared('view', function () { $view = new View(); - $view->setViewsDir('../App/Views/'); + $view->setViewsDir('../app/Views/'); return $view; }); @@ -34,10 +34,10 @@ $di->setShared('db', function () { return new Database( [ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "invo" + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); }); diff --git a/single-camelized-dirs/app/Views/Index/Index.phtml b/single-camelized-dirs/app/Views/Index/Index.phtml index 71f45ae..06cf508 100644 --- a/single-camelized-dirs/app/Views/Index/Index.phtml +++ b/single-camelized-dirs/app/Views/Index/Index.phtml @@ -1,3 +1,3 @@

Hello

-tag->linkTo('products', 'Products') ?> +tag->a('products', 'Products') ?> diff --git a/single-camelized-dirs/public/index.php b/single-camelized-dirs/public/index.php index 9382c96..876d31b 100644 --- a/single-camelized-dirs/public/index.php +++ b/single-camelized-dirs/public/index.php @@ -1,11 +1,11 @@ getDispatcher(); - + $helper = $di->getHelper(); $view->render( - Text::camelize($dispatcher->getControllerName()), - Text::camelize($dispatcher->getActionName()), + $helper->camelize($dispatcher->getControllerName()), + $helper->camelize($dispatcher->getActionName()), $dispatcher->getParams() ); } @@ -28,7 +28,7 @@ function ($event, $application, $view) use ($di) { $application->setEventsManager($eventsManager); - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); } catch (\Exception $e) { diff --git a/single-factory-default/app/config/config.php b/single-factory-default/app/config/config.php index 81b5906..723bf7b 100644 --- a/single-factory-default/app/config/config.php +++ b/single-factory-default/app/config/config.php @@ -1,6 +1,6 @@ registerDirs( + $loader->setDirectories( [ $config->application->controllersDir, $config->application->modelsDir @@ -77,8 +78,14 @@ * Start the session the first time some component request the session service */ $di->set('session', function () { - $session = new Session(); - $session->start(); + $session = new SessionManager(); + $files = new SessionFiles([ + 'savePath' => '/tmp', + ]); + + $session + ->setAdapter($files) + ->start(); return $session; }); @@ -87,7 +94,7 @@ */ $application = new Application($di); - $response = $application->handle(); + $response = $application->handle($_SERVER["REQUEST_URI"]); $response->send(); } catch (\Exception $e) { diff --git a/single-namespaces/public/index.php b/single-namespaces/public/index.php index 959eced..1f9d649 100644 --- a/single-namespaces/public/index.php +++ b/single-namespaces/public/index.php @@ -2,8 +2,8 @@ namespace Single; -use Phalcon\DI; -use Phalcon\Loader; +use Phalcon\DI\Di; +use Phalcon\Autoload\Loader; use Phalcon\Mvc\View; use Phalcon\Mvc\Router; use Phalcon\Mvc\Dispatcher; @@ -20,7 +20,7 @@ protected function registerAutoloaders() { $loader = new Loader(); - $loader->registerNamespaces( + $loader->setNamespaces( [ 'Single\Controllers' => '../apps/controllers/', 'Single\Models' => '../apps/models/' @@ -71,10 +71,10 @@ protected function registerServices() $di->set('db', function () { return new Database( [ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "invo" + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); }); @@ -97,7 +97,7 @@ public function main() $this->registerServices(); $this->registerAutoloaders(); - $response = $this->handle(); + $response = $this->handle($_SERVER["REQUEST_URI"]); $response->send(); } diff --git a/single-service-provider/app/Bootstrap.php b/single-service-provider/app/Bootstrap.php index 4d0ba10..d387b14 100644 --- a/single-service-provider/app/Bootstrap.php +++ b/single-service-provider/app/Bootstrap.php @@ -2,8 +2,8 @@ namespace App; -use Phalcon\Di; -use Phalcon\DiInterface; +use Phalcon\Di\Di; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\Application; use App\Providers\ServiceProviderInterface; @@ -103,12 +103,12 @@ public function run() protected function getOutput() { if ($this->app instanceof Application) { - $response = $this->app->handle(); + $response = $this->app->handle($_SERVER["REQUEST_URI"]); return $response->getContent(); } - return $this->app->handle(); + return $this->app->handle($_SERVER["REQUEST_URI"]); } /** diff --git a/single-service-provider/app/Providers/AbstractServiceProvider.php b/single-service-provider/app/Providers/AbstractServiceProvider.php index 5d278d7..65237fa 100644 --- a/single-service-provider/app/Providers/AbstractServiceProvider.php +++ b/single-service-provider/app/Providers/AbstractServiceProvider.php @@ -2,15 +2,15 @@ namespace App\Providers; -use Phalcon\DiInterface; -use Phalcon\Mvc\User\Component; +use Phalcon\Di\DiInterface; +use Phalcon\Di\Injectable; /** * \App\Providers\AbstractServiceProvider * * @package App\Providers */ -abstract class AbstractServiceProvider extends Component implements ServiceProviderInterface +abstract class AbstractServiceProvider extends Injectable implements ServiceProviderInterface { /** * The Service name. diff --git a/single-service-provider/app/Providers/ConfigServiceProvider.php b/single-service-provider/app/Providers/ConfigServiceProvider.php index bddef38..facaf46 100644 --- a/single-service-provider/app/Providers/ConfigServiceProvider.php +++ b/single-service-provider/app/Providers/ConfigServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Phalcon\Config; +use Phalcon\Config\Config; /** * \App\Providers\ConfigServiceProvider @@ -27,12 +27,11 @@ public function register() $this->di->setShared( $this->serviceName, function () { - /** @var \Phalcon\DiInterface $this */ + /** @var \Phalcon\Di\DiInterface $this */ $config = []; $appPath = $this->getShared('bootstrap')->getApplicationPath(); if (file_exists($appPath . '/config/application.php')) { - /** @noinspection PhpIncludeInspection */ $config = include $appPath . '/config/application.php'; } diff --git a/single-service-provider/app/Providers/DatabaseServiceProvider.php b/single-service-provider/app/Providers/DatabaseServiceProvider.php index 41c59f6..486bbcf 100644 --- a/single-service-provider/app/Providers/DatabaseServiceProvider.php +++ b/single-service-provider/app/Providers/DatabaseServiceProvider.php @@ -27,7 +27,7 @@ public function register() $this->di->setShared( $this->serviceName, function () { - /** @var \Phalcon\DiInterface $this */ + /** @var \Phalcon\Di\DiInterface $this */ $connection = new Mysql($this->getShared('config')->database->toArray()); return $connection; diff --git a/single-service-provider/app/Providers/EscaperServiceProvider.php b/single-service-provider/app/Providers/EscaperServiceProvider.php index 7db39d3..249f8a4 100644 --- a/single-service-provider/app/Providers/EscaperServiceProvider.php +++ b/single-service-provider/app/Providers/EscaperServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Phalcon\Escaper; +use Phalcon\Html\Escaper; /** * \App\Providers\EscaperServiceProvider diff --git a/single-service-provider/app/Providers/PhpTemplateEngineServiceProvider.php b/single-service-provider/app/Providers/PhpTemplateEngineServiceProvider.php index 42483f9..cf44384 100644 --- a/single-service-provider/app/Providers/PhpTemplateEngineServiceProvider.php +++ b/single-service-provider/app/Providers/PhpTemplateEngineServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\ViewBaseInterface; use Phalcon\Mvc\View\Engine\Php as PhpEngine; diff --git a/single-service-provider/app/Providers/RouterServiceProvider.php b/single-service-provider/app/Providers/RouterServiceProvider.php index ba213c0..c2c029a 100644 --- a/single-service-provider/app/Providers/RouterServiceProvider.php +++ b/single-service-provider/app/Providers/RouterServiceProvider.php @@ -25,7 +25,7 @@ public function register() $this->di->setShared( $this->serviceName, function () { - /** @var \Phalcon\DiInterface $this */ + /** @var \Phalcon\Di\DiInterface $this */ $appPath = $this->getShared('bootstrap')->getApplicationPath(); return require $appPath . '/app/Http/routes.php'; diff --git a/single-service-provider/app/Providers/SessionServiceProvider.php b/single-service-provider/app/Providers/SessionServiceProvider.php index df4766c..c5f4c5a 100644 --- a/single-service-provider/app/Providers/SessionServiceProvider.php +++ b/single-service-provider/app/Providers/SessionServiceProvider.php @@ -2,7 +2,8 @@ namespace App\Providers; -use Phalcon\Session\Adapter\Files; +use Phalcon\Session\Adapter\Stream as SessionFiles; +use Phalcon\Session\Manager as SessionManager; /** * \App\Providers\SessionServiceProvider @@ -27,9 +28,14 @@ public function register() $this->di->setShared( $this->serviceName, function () { - $session = new Files(); - $session->start(); + $session = new SessionManager(); + $files = new SessionFiles([ + 'savePath' => '/tmp', + ]); + $session + ->setAdapter($files) + ->start(); return $session; } ); diff --git a/single-service-provider/app/Providers/TagServiceProvider.php b/single-service-provider/app/Providers/TagServiceProvider.php index 55c2d7b..4a412ba 100644 --- a/single-service-provider/app/Providers/TagServiceProvider.php +++ b/single-service-provider/app/Providers/TagServiceProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use Phalcon\Session\Adapter\Stream as SessionFiles; +use Phalcon\Session\Manager as SessionManager; use Phalcon\Tag; /** @@ -24,6 +26,19 @@ class TagServiceProvider extends AbstractServiceProvider */ public function register() { - $this->di->setShared($this->serviceName, Tag::class); + $this->di->setShared( + $this->serviceName, + function () { + $session = new SessionManager(); + $files = new SessionFiles([ + 'savePath' => '/tmp', + ]); + + $session + ->setAdapter($files) + ->start(); + return $session; + } + ); } } diff --git a/single-service-provider/app/Providers/UrlResolverServiceProvider.php b/single-service-provider/app/Providers/UrlResolverServiceProvider.php index 0f258b6..f1e643c 100644 --- a/single-service-provider/app/Providers/UrlResolverServiceProvider.php +++ b/single-service-provider/app/Providers/UrlResolverServiceProvider.php @@ -29,7 +29,7 @@ public function register() function () { $url = new Url(); - /** @var \Phalcon\DiInterface $this */ + /** @var \Phalcon\Di\DiInterface $this */ $url->setBaseUri($this->getShared('application')->baseUri); return $url; diff --git a/single-service-provider/app/Providers/ViewServiceProvider.php b/single-service-provider/app/Providers/ViewServiceProvider.php index 455e25d..f622f8f 100644 --- a/single-service-provider/app/Providers/ViewServiceProvider.php +++ b/single-service-provider/app/Providers/ViewServiceProvider.php @@ -27,7 +27,7 @@ public function register() $this->di->setShared( $this->serviceName, function () { - /** @var \Phalcon\DiInterface $this */ + /** @var \Phalcon\Di\DiInterface $this */ $config = $this->getShared('config')->application; $view = new View(); diff --git a/single-service-provider/app/Providers/VoltTemplateEngineServiceProvider.php b/single-service-provider/app/Providers/VoltTemplateEngineServiceProvider.php index 36371c6..6fc72d8 100644 --- a/single-service-provider/app/Providers/VoltTemplateEngineServiceProvider.php +++ b/single-service-provider/app/Providers/VoltTemplateEngineServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Phalcon\DiInterface; +use Phalcon\Di\DiInterface; use Phalcon\Mvc\View\Engine\Volt; use Phalcon\Mvc\ViewBaseInterface; @@ -29,15 +29,15 @@ public function register() $this->di->setShared( $this->serviceName, function (ViewBaseInterface $view, DiInterface $di = null) { - /** @var \Phalcon\DiInterface $this */ + /** @var DiInterface $this */ $config = $this->getShared('config')->volt; $volt = new Volt($view, $di); $volt->setOptions( [ - 'compiledPath' => $config->cacheDir, - 'compiledSeparator' => $config->compiledSeparator + 'path' => $config->cacheDir, + 'separator' => $config->compiledSeparator ] ); diff --git a/single-service-provider/bootstrap/autoload.php b/single-service-provider/bootstrap/autoload.php index d4ba19e..8005642 100644 --- a/single-service-provider/bootstrap/autoload.php +++ b/single-service-provider/bootstrap/autoload.php @@ -1,10 +1,10 @@ registerNamespaces(['App' => dirname(dirname(__FILE__)) . '/app/']); +$loader->setNamespaces(['App' => dirname(dirname(__FILE__)) . '/app/']); $loader->register(); diff --git a/single/public/index.php b/single/public/index.php index 90d7e25..0d00a97 100644 --- a/single/public/index.php +++ b/single/public/index.php @@ -1,7 +1,7 @@ registerDirs( + $loader->setDirectories( [ "../apps/controllers/", "../apps/models/", @@ -84,10 +84,10 @@ function () { function () { return new Database( [ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "invo", + 'host' => 'localhost', + 'username' => 'phalcon', + 'password' => 'secret', + 'dbname' => 'phalcon_invo', ] ); } @@ -108,6 +108,13 @@ function () { return new ModelsManager(); } ); + + $di->set( + 'tag', + function () { + return new \Phalcon\Html\TagFactory(new \Phalcon\Html\Escaper()); + } + ); $this->setDI($di); } @@ -117,7 +124,7 @@ public function main() $this->registerServices(); $this->registerAutoloaders(); - $response = $this->handle(); + $response = $this->handle($_SERVER["REQUEST_URI"]); $response->send(); }