fuxie / utopia-php-framework
A simple, light and advanced PHP framework
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2015-07-17 09:22:03 UTC
README
Utopia Framework is an MVC based framework with minimal must-have features for professional and advanced web development. Any extra features such as authentication, caching will be available as standalone models in order to keep the framework core as clean, light any easy to learn.
As of version 1.0 RC4 Utopia core consists of only 14 files and less than 1500 lines of code.
Example Application
Structure
- app
- controllers
- DefaultController.php
- models
- Router.php
- views
- app/view/default/index.phtml
- controllers
- public
- styles
- scripts
- index.php
public/index.php
require '../vendor/autoload.php';
$utopia = Utopia\Application::getInstance()
->setRouter(new Skeleton\Router)
;
$utopia->run();
app/models/Router.php
namespace Skeleton;
class Router extends \Utopia\Router {
public function init()
{
}
/**
* @return String
*/
public function getController()
{
return 'default';
}
/**
* @return String
*/
public function getAction()
{
return 'index';
}
/**
* @param string $action
* @param string $controller
* @param array $vars
* @return string
*/
public function getUrl($action, $controller, array $vars = array())
{
return '/?controller=default&action=index';
}
}
app/controllers/DefaultController.php
use Utopia\Controller;
class DefaultController extends Controller {
public function init()
{
$this->getResponse()
->addHeader('X-UA-Compatible', 'IE=Edge');
$this->getLayout()
->setPath('../app/views/layout.phtml')
->addStyle('/styles/normalize.css')
->setTitle('Utopia Skeleton Application')
;
}
public function indexAction()
{
$this->getView()
->setParam('param1', 'value1')
->setParam('param2', 'value2')
;
}
}
app/view/default/index.phtml
<?php
/* @var $this Utopia\View */
$param1 = $this->getParam('param1', 'default1');
$param2 = $this->getParam('param2', 'default2');
$param3 = $this->getParam('param3', 'default3');
?>
<h1>Hello World!</h1>
<h2>Example usage of the view parameters</h2>
<ul>
<li>Param1: <?php echo $param1; ?></li>
<li>Param2: <?php echo $param2; ?></li>
<li>Param3: <?php echo $param3; ?></li>
</ul>
System Requirements
Utopia Framework requires PHP 5.4 or later. We recommend using the latest PHP version whenever possible.
Versioning
For transparency and insight into our release cycle, and for striving to maintain backward compatibility, Utopia PHP Framework will be maintained under the Semantic Versioning guidelines as much as possible. Releases will be numbered with the following format:
<major>.<minor>.<patch>
For more information on SemVer, please visit http://semver.org/.
Travis CI
Travis CI is a continuous integration service, which can monitor GitHub for new commits to your repository and execute scripts such as building the app or running tests. The Utopia-PHP-Framework project contains a Travis configuration file, .travis.yml, which will cause Travis to run your tests when you push to GitHub.
You will need to enable the integration between Travis and GitHub. See the Travis website for more instruction on how to do this.
Authors
Eldad Fux
Links
- GIT Repositiory: https://github.com/eldadfux/Utopia-PHP-Framework
- Application Sekeleton: https://github.com/eldadfux/Utopia-PHP-Framework-Skeleton
- Contributors: https://github.com/eldadfux/Utopia-PHP-Framework/contributors
Copyright and license
The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php