dev-master
9999999-dev http://noframework.comClear fast flexible lightweight php 5.5 framework
MIT
The Requires
- php >=5.5
by Roman Zaykin
orm dependency injection php minimal psr-0 memoization noframework virtual database
Wallogit.com
2017 © Pedro Peláez
Clear fast flexible lightweight php 5.5 framework
(PHP 5 >= 5.5), (*1)
<?php
require __DIR__ . '/../class.php/NoFramework/Config.php';
// Read comments in Config.php for yaml examples
// example.yaml should reside in '.config' up from script path
// (i.e. '../.config' or '../../.config', and so on until found)
(new NoFramework\Config)->parse('example.yaml')->application->start();
<?php
require __DIR__ . '/../class.php/NoFramework/Autoload.php';
(new NoFramework\Autoload)->register();
(new NoFramework\Autoload([
'namespace' => 'Example',
'path' => __DIR__ . '/../class.php/Example',
])->register();
(new Example\Factory([
// Object of class Example\Logger will be instantiated as property 'log'
// in object of class Example\Service instantiated in property 'service'.
// If Example\Service does not exist, then it will be Example\Factory
'service.log' => ['$new' => 'Logger'],
]))->service->start();
class SomeClass
{
use \NoFramework\Magic;
protected $default = 'default value';
// Memoization
// (same as default value, but calculated)
protected function __property_pid()
{
echo 'calculated' . PHP_EOL;
return posix_getpid();
}
public function callMe()
{
var_dump($this->pid);
var_dump($this->pid);
var_dump($this->pid);
}
}
Suppose we create project in /home/example.com, (*2)
Maybe you wish to create that user, not only a directory:, (*3)
useradd example.com
Copy NoFramework and Twig into /home/example.com/class.php directory:, (*4)
git clone https://github.com/NoFramework/NoFramework git clone https://github.com/fabpot/Twig
Create /home/example.com/.cache and make it writable for php-fpm user or for all, (*5)
Create /home/example.com/index.php:, (*6)
<?php
namespace NoFramework;
$debug = true;
ini_set('date.timezone', 'UTC');
ini_set('display_startup_errors', $debug);
ini_set('display_errors', $debug);
require __DIR__ . '/class.php/NoFramework/Autoload.php';
(new Autoload)->register();
(new Autoload([
'namespace' => 'Twig',
'path' => __DIR__ . '/class.php/Twig/lib/Twig',
'separator' => '_',
]))->register();
(new Http\Application([
'namespace' => __NAMESPACE__,
'template' => ['$new' => [
'class' => 'Template\Twig',
'path' => __DIR__ . '/template',
'cache' => __DIR__ . '/.cache/twig',
'search_path' => 'landing',
'auto_reload' => $debug,
'debug' => $debug, // enable 'dump' function
]]
]))->start();
Edit /etc/hosts on server and set ip of example.com explicitly., (*7)
Create /home/example.com/nginx.include:, (*8)
server {
listen example.com;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen example.com;
server_name example.com;
root /home/$host;
location = /favicon.ico {
empty_gif;
}
location / {
fastcgi_pass unix:/var/run/php5-fpm.sock; #debian default
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
}
ln -s /home/example.com/nginx.include /etc/nginx/conf.d/example.com.conf
Put some html in:, (*9)
/home/example.com/template/landing/index.html.twig /home/example.com/template/landing/some_page.html.twig /home/example.com/template/landing/some_dir/some_other_page.html.twig ... and so on
Restart nginx, (*10)
Edit /etc/hosts on your local machine if necessary, (*11)
Visit:, (*12)
http://example.com/ http://example.com/some_page/ http://example.com/some_dir/some_other_page/ ... and so on
Clear fast flexible lightweight php 5.5 framework
MIT
orm dependency injection php minimal psr-0 memoization noframework virtual database