Awesome Open Source
Awesome Open Source

SlightPHP PHP

composer,php5.3

//
composer config -g repo.packagist composer https://packagist.phpcomposer.com
//
composer require "hetao29/slightphp:dev-master"
  • composer.json composer install
{
    "require": {
        "hetao29/slightphp": "dev-master"
    }
}
composer dump-autoload --optimize
  • v2.0 SlightPHP.phpslightphp_path
<?php
//require_once($slightphp_path."/SlightPHP.php"); #
require_once($slightphp_path."/vendor/autoload.php");
  • v2.0php4,php5,php7

pecl php7

  • php7
  • composer

  • """plugins"
  • composer(3.0)
  • php7(3.0)
  • pecl peclphp
  • (cli) SlightPHP::run($path_info) WorkerMan,Swoole PHP
  • nginx,lighttpd,apache,iisweb
  • SDb mysql,mysqli,pdo,mssql,oracle
  • SRoute URL
  • STplSmarty
  • SCache(memcache)consistent hashingKEYfile,apc
  • wikisamples

Hello, world!

index.php

<?php
//1
require_once("SlightPHP.php");

//2PHP
//dl("slightphp.so");
//php.inidl
//extension = slightphp.so

//3composerautoload
//require_once("vendor/autoload.php");

SlightPHP::run();
?>

index.phpzonezonepage.page.php

<?php 
class zone_page{ 
    function PageEntry($inPath){
        echo "Hello, world!";
    } 
} 
?>

index.php

http://localhost/index.php

zone "zone"
page .page.php"page"
entry Page"entry"
appDir "."
splitFlag "/"
inPath entry

http://localhost/index.php http://localhost/index.php/zone/page/entry $appDir/zone/page.page.phppageEntry

<?php
SlightPHP::setDefaultZone("user");
SlightPHP::setDefaultPage("profile");
SlightPHP::setDefaultEntry("update");
?>

http://localhost/index.php $appDir/user/profile.page.phppageUpdate http://localhost/index.php/user/profile/update URL

-

SlightPHP::setZoneAlias("user","u");
SlightPHP::setPageAlias("profile","p");

http://localhost/index.php/u/p/update http://localhost/index.php/user/profile/update

useru

(splitFlag)

zone,page,entry/

SlightPHP::setSplitFlag(".")

http://localhost/index.php/user.profile.update .html http://localhost/index.php/user.profile.update.html ,

SlightPHP::setSplitFlag("-.")

http://localhost/index.php/user-profile-update.html

Apache Rewrite

.htaccessapache

RewriteEngine   on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

http://localhost/user/profile/update

SlightPHP::setSplitFlag(".");

http://localhost/user.profile.update

http://localhost/profile/update apache

RewriteRule   ^(/profile/.*)$ /index.php/user/profile/update/$1 [E=PATH_INFO:$1,L]

$inPath

  • $inPath[0] zone
  • $inPath[1] page
  • $inPath[2] entry
  • $inPath[...] html

http://localhost/index.php/user/profile/update/other1/other2/... inPath $inPath=array("user","profile","update","other1","other2","...")

appDir

SlightPHP::setAppDir("/home/www/myAppdir");

http://localhost/index.php/user/profile/update

/home/www/myAppdir/user/profile.page.phppageUpdate

appDir

Wikihttps://github.com/hetao29/slightphp/tree/master/wiki
APIhttp://hetao29.github.io/slightphp/

STpl https://github.com/hetao29/slightphp/blob/master/wiki/STpl.md
SDb https://github.com/hetao29/slightphp/blob/master/wiki/SDb.md

SCache Memcache,File,Apc https://github.com/hetao29/slightphp/blob/master/wiki/SCache.md
SRedis Redis https://github.com/hetao29/slightphp/blob/master/wiki/SRedis.md
SConfig https://github.com/hetao29/slightphp/blob/master/wiki/SConfig.md
SRoute https://github.com/hetao29/slightphp/blob/master/wiki/SRoute.md
SError https://github.com/hetao29/slightphp/blob/master/wiki/SError.md
...

samples

Nginx

location / {
	root   /var/www/slightphp/samples/www;
	index  index.php;
	if (!-e $request_filename){
		rewrite ^/(.+?)$ /index.php last;
	}
}
location ~ \.php$ {
	fastcgi_pass   127.0.0.1:9000;
	fastcgi_index  index.php;
	fastcgi_param  SCRIPT_FILENAME  /var/www/slightphp/samples/www$fastcgi_script_name;
	include        fastcgi_params;
}

Version

3.2

Free Software, MIT License!


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Php (402,785
Mysql (12,078
Database (9,343
Framework (6,686
Composer (2,221
Swoole (538
Related Projects