Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapted to v5 namespaces, methods #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hmvc/public/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Phalcon\Loader;
use Phalcon\DiInterface;
use Phalcon\Autoload\Loader;
use Phalcon\Di\DiInterface;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Http\ResponseInterface;
Expand All @@ -19,7 +19,7 @@ public function __construct(DiInterface $di)
$loader = new Loader();

// Application Loader
$loader->registerDirs(
$loader->setDirectories(
[
"../app/controllers/",
]
Expand Down Expand Up @@ -100,6 +100,6 @@ public function request(array $location, $data = null)



$response = $app->handle();
$response = $app->handle($_SERVER["REQUEST_URI"]);

$response->send();
2 changes: 1 addition & 1 deletion micro-factory-default/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

return new Config(
[
Expand Down
6 changes: 3 additions & 3 deletions micro-factory-default/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

error_reporting(E_ALL);

use Phalcon\Loader;
use Phalcon\Autoload\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as Database;
Expand Down Expand Up @@ -46,7 +46,7 @@
$loader = new Loader();

$loader
->registerDirs([$config->application->modelsDir])
->setDirectories([$config->application->modelsDir])
->register();

/**
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion micro-simple-views/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

$config = new Config(
[
Expand Down
16 changes: 12 additions & 4 deletions micro-simple-views/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

$view->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' => '_',
]
);

Expand All @@ -47,3 +47,11 @@

return $view;
});


$di->setShared(
'tag',
function () {
return new \Phalcon\Html\TagFactory(new \Phalcon\Html\Escaper());
}
);
2 changes: 1 addition & 1 deletion micro-simple-views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
echo $app['view']->render('500');
});

$app->handle();
$app->handle($_SERVER["REQUEST_URI"]);
2 changes: 1 addition & 1 deletion micro-simple-views/views/500.volt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1>500 Error</h1>

<?php echo $this->tag->linkTo('index', 'Go Home') ?>
<?php echo $this->tag->a('index', 'Go Home') ?>
2 changes: 1 addition & 1 deletion micro-simple-views/views/index.volt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1>Welcome</h1>

<?php echo $this->tag->linkTo('', 'Go Home') ?>
<?php echo $this->tag->a('index', 'Go Home') ?>
2 changes: 1 addition & 1 deletion micro/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ function () use ($app) {
}
);

$app->handle();
$app->handle($_SERVER["REQUEST_URI"]);
6 changes: 3 additions & 3 deletions multiple-factory-default/apps/frontend/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/',
Expand Down
2 changes: 1 addition & 1 deletion multiple-factory-default/apps/frontend/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

return new Config(
[
Expand Down
6 changes: 3 additions & 3 deletions multiple-factory-default/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
]
);

$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();
}
8 changes: 4 additions & 4 deletions multiple-service-layer-model/apps/config/config.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

return new Config(
[
'database' => [
'adapter' => 'Mysql',
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'phalcon',
'username' => 'phalcon',
'password' => 'secret',
'dbname' => 'phalcon_invo',
],
'application' => [
'controllersDir' => __DIR__ . '/../controllers/',
Expand Down
12 changes: 8 additions & 4 deletions multiple-service-layer-model/apps/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions multiple-service-layer-model/apps/models/entities/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -200,8 +200,4 @@ public function validation()
return $this->validate($validator);
}

public function getSource()
{
return 'user';
}
}
6 changes: 3 additions & 3 deletions multiple-service-layer-model/apps/modules/frontend/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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/',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php echo $users[0]->getName(); ?>
6 changes: 3 additions & 3 deletions multiple-service-layer-model/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
6 changes: 3 additions & 3 deletions multiple-shared-layouts/apps/backend/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/',
Expand Down
2 changes: 1 addition & 1 deletion multiple-shared-layouts/apps/backend/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

return new Config(
[
Expand Down
6 changes: 3 additions & 3 deletions multiple-shared-layouts/apps/frontend/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/',
Expand Down
2 changes: 1 addition & 1 deletion multiple-shared-layouts/apps/frontend/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Phalcon\Config;
use Phalcon\Config\Config;

return new Config(
[
Expand Down
6 changes: 3 additions & 3 deletions multiple-shared-layouts/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
]
);

$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();
}
14 changes: 7 additions & 7 deletions multiple-shared-views/apps/modules/backend/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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/",
Expand Down Expand Up @@ -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',
]
);
}
Expand Down
Loading