upcloo / micro-framework
Just a simple micro-framework built in top of ZF2 components
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 0
Type:framework
Requires
- zendframework/zend-eventmanager: 2.2.*
- zendframework/zend-http: 2.2.*
- zendframework/zend-mvc: 2.2.*
- zendframework/zend-servicemanager: 2.2.*
Requires (Dev)
- behat/behat: 2.4.*@stable
- phpunit/phpunit: 3.7.*
README
This is just a simple microframework based on ZF2 components.
License
This project is released under MIT license.
##Getting started
In the scenario
folder you can find not only an example but a typical starting
point...
You can use a project folder that you prefer but a good starting point is:
- src
- Your
- Namespace
- tests
- Your
- Namespace
- web
- configs
The entry point (web/index.php)
<?php
$loader = include __DIR__ . '/vendor/autoload.php';
$loader->add("Your", __DIR__ . '/../src');
$config = new UpCloo\App\Config\ArrayProcessor();
$config->appendConfig(include __DIR__ . '/../configs/app.php');
$engine = new UpCloo\App\Engine();
$boot = new UpCloo\App\Boot($config);
$app = new UpCloo\App($engine, $boot);
$app->run();
Here is a config (configs/app.php)
<?php
return array(
"router" => array(
"routes" => array(
"home" => array(
"type" => "Literal",
"options" => array(
"route" => "/walter",
'defaults' => array(
'controller' => 'Your\\Controller\\Name',
'action' => 'hello'
)
),
'may_terminate' => true,
)
)
),
"services" => array(
"invokables" => array(
"Your\\Controller\\Name" => "Your\\Controller\\Name",
),
"factories" => array(
"example" => function(\Zend\ServiceManager\ServiceLocatorInterface $sl) {
return "hello";
}
),
)
);
Start with a controller (src/Your/Controller/Name.php)
<?php
namespace Your\Controller;
use UpCloo\Controller\ServiceManager;
class Name
{
use ServiceManager;
public function hello()
{
$hello = $this->services()->get("example");
return $hello . " " . "world";
}
}
Start your web service
php -S localhost:8080 -t web/ web/index.php
Go to your page -> localhost:8080/walter