What I'm doing is basically ripping off the Vokuro code and changing a couple things, but it's not working for me. The "default" route is working, but the /login and /pricing routes return a 404. mod_rewrite is enabled.
router.php:
<?php
/*
* Define custom routes. File gets included in the router service definition.
*/
$router = new Phalcon\Mvc\Router();
$router->addGet('/login',[
'controller' => 'noauthpages',
'action' => 'login'
]);
$router->addGet('/pricing',[
'controller' => 'noauthpages',
'action' => 'pricing'
]);
$router->setDefaults([
'controller' => 'noauthpages',
'action' => 'index'
]);
return $router;
services.php:
<?php
use Phalcon\Mvc\View;
use Phalcon\Crypt;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
//use Phalcon\Mvc\Model\Metadata\Files as MetaDataAdapter;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Logger\Adapter\File as FileLogger;
use Phalcon\Logger\Formatter\Line as FormatterLine;
/**
* Register the global configuration as config
*/
$di->setShared('config', function () {
return include APP_PATH . "/config/config.php";
});
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->setShared('url', function () {
$config = $this->getConfig();
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Setting up the view component
*/
$di->set('view', function () {
$config = $this->getConfig();
$view = new View();
$view->setViewsDir($config->application->viewsDir);
return $view;
}, true);
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->set('db', function () {
$config = $this->getConfig();
return new DbAdapter([
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname
]);
});
/**
* If the configuration specify the use of metadata adapter use it or use memory otherwise
*/
/*
$di->set('modelsMetadata', function () {
$config = $this->getConfig();
return new MetaDataAdapter([
'metaDataDir' => $config->application->cacheDir . 'metaData/'
]);
});
*/
/**
* Start the session the first time some component request the session service
*/
$di->set('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
/**
* Crypt service
*/
$di->set('crypt', function () {
$config = $this->getConfig();
$crypt = new Crypt();
$crypt->setKey($config->application->cryptSalt);
return $crypt;
});
/**
* Dispatcher use a default namespace
*/
$di->set('dispatcher', function () {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Zipline\Controllers');
return $dispatcher;
});
/**
* Loading routes from the routes.php file
*/
$di->set('router', function () {
return require APP_PATH . '/config/routes.php';
});
/**
* Logger service
*/
$di->set('logger', function ($filename = null, $format = null) {
$config = $this->getConfig();
$format = $format ?: $config->get('logger')->format;
$filename = trim($filename ?: $config->get('logger')->filename, '\\/');
$path = rtrim($config->get('logger')->path, '\\/') . DIRECTORY_SEPARATOR;
$formatter = new FormatterLine($format, $config->get('logger')->date);
$logger = new FileLogger($path . $filename);
$logger->setFormatter($formatter);
$logger->setLogLevel($config->get('logger')->logLevel);
return $logger;
});
loader.php:
<?php
use Phalcon\Loader;
$loader = new Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerNamespaces([
'Zipline\Models' => $config->application->modelsDir,
'Zipline\Controllers' => $config->application->controllersDir,
//'Zipline\Forms' => $config->application->formsDir,
'Zipline' => $config->application->libraryDir
]);
$loader->register();
// Use composer autoloader to load vendor classes
require_once BASE_PATH . '/vendor/autoload.php';
I didn't change anything on the index.php page.
Anyway, not sure why the default route works, but the others don't.