About

PHP framework, routes, controllers and views

Requirements

PHP 5.3.0+ Multibyte String (GD also) (optional, only used in InphinitHelper::toAscii) libiconv (optional, only used in InphinitHelper::toAscii) fileinfo (optional, only used in InphinitFile::mime) Apache or Nginx or IIS for production

For check requirements see Check requirements

Getting start

Have two method for install First method is using composers Download Composer and install For create an project in Windows:

cd c:wampwww composer create-project inphinit/inphinit [project_name] Or (if no using Wamp/Xampp/easyphp)

cd c:Users[username]Documents composer create-project inphinit/inphinit [project_name] Install in Unix-like:

cd /var/www/ php composer.phar create-project inphinit/inphinit [project_name] Or (if no using Apache)

cd /home/ php composer.phar create-project inphinit/inphinit [project_name] Alternate is download GIT repository and copy content from zip file to folder project (don't clone master for production use), clone last release example:

git clone -b 0.5.17 --recurse-submodules https://github.com/inphinit/inphinit.git [project_name] cd [project_name]

Note: Don't use composer dev-master (eg. create-projet inphinit/inphinit:dev-master), to collaborate, prefer to clone with GIT, example:

git clone --recurse-submodules https://github.com/inphinit/inphinit.git inphinit cd inphinit

Apache

If using Apache (or Xampp, Wamp, Easyphp, etc) only navigate to http://localhost/[project_name]/ Navigate http://localhost/[project_name]/generate-htaccess.php for create .htaccess

PHP built-in web server in Windows

Navigate with explorer.exe to project folder Find and edit server.bat, change php.exe path and php.ini for your php path:

set PHP_BIN="C:phpphp.exe" set PHP_INI="C:phpphp.ini" set HOST_PORT=9000 Save the edition and run server.bat Open webbrowser and navigate to http://localhost:9000

PHP built-in web server in Linux and Mac (or Unix-like)

If using Linux or Mac navigate to project folder and run using terminal:

cd /home/[project_name]/ php -S localhost:9000 system/boot/server.php Open web-browser and navigate to http://localhost:9000 Or edit server

#!/bin/bash PHP_BIN="/usr/bin/php" PHP_INI="/etc/php5/cli/php.ini" HOST_PORT=9000 Save edition and run ./server

Routing

In folder [project_name]/system/ find main.php and put something like this:

Route::set('GET', '/foo', 'MyController:action');

In [project_name]/system/application/Controller/ folder create an file with this name MyController.php (case sensitive)

Put this content:

<?php namespace Controller; use InphinitViewingView; class MyController { public function action() { $data = array( 'foo' => 'Hello', 'Baz' => 'World!' ); View::render('myview', $data); } }

In [project_name]/system/application/View/ create file with this name myview.php (case sensitive) and put:

<p><?php echo $foo, ' ', $baz; ?></p>

Navigate to http://localhost:9000/foo or http://localhost/[project_name]/foo

Check requirements

For check requirements navigate with your web-browser to http://localhost:9000/check.php or http://localhost/[project_name]/check.php

Development vs production

For setup access [project_name]/system/application/Config/config.php with your text editor and change development key to true or false:

<?php return array( 'appdata_expires' => 86400, 'development' => true, 'maintenance' => false );

Nginx

For create nginx config run with terminal:

cd /home/[project_name]/ php generate-nginx.php

And copy content to clipboard and adjust nginx.conf

IIS

Install PHP:

Download PHP: http://windows.php.net/download/ Install PHP to %SYSTEMROOT%php (like c:php, d:php)

IIS Express

Installing in IIS Express:

Navigate to %USERPROFILE%DocumentsIISExpressconfig Edit applicationHost.config And put in file this:

<location path="WebSite1"> <system.webServer> <handlers> <add name="PHP_via_FastCGI" path="*.php" verb="" modules="FastCgiModule" scriptProcessor="c:PHPphp-cgi.exe" resourceType="Either" /> </handlers> </system.webServer> </location> Restart IIS Copy contents in %USERPROFILE%DocumentsMy Web SitesWebSite1 You can create a new website, so just change WebSite1 to the new folder.

For more details in https://msdn.microsoft.com/en-us/library/hh994590(v=ws.11).aspx

Default IIS

Navigate to %windir%System32inetsrvconfig Edit applicationHost.config (requires Administrator Privileges) And put in file this like this:

<defaultDocument enabled="true"> <files> <add value="index.php" /> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> </files> </defaultDocument> <fastCgi> <application fullPath="C:phpphp-cgi.exe" monitorChangesTo="C:phpphp.ini" activityTimeout="300" requestTimeout="300" instanceMaxRequests="10000"> <environmentVariables> <environmentVariable name="PHPRC" value="C:php" /> <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" /> </environmentVariables> </application> </fastCgi> And after put:

<handlers accessPolicy="Read, Script"> <add name="PHP_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:phpphp-cgi.exe" resourceType="Either" />

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。