Giter Site home page Giter Site logo

About

PHP framework, routes, controllers and views

Requirements

  1. PHP 5.3.0+
  2. Multibyte String (GD also) (optional, only used in Inphinit\Helper::toAscii)
  3. libiconv (optional, only used in Inphinit\Helper::toAscii)
  4. fileinfo (optional, only used in Inphinit\File::mime)
  5. Apache or Nginx or IIS for production

For check requirements see Check requirements

Getting start

  1. Have two method for install
  2. First method is using composers
  3. Download Composer and install
  4. For create an project in Windows:
    cd c:\wamp\www\
    composer create-project inphinit/inphinit [project_name]
  5. Or (if no using Wamp/Xampp/easyphp)
    cd c:\Users\[username]\Documents\
    composer create-project inphinit/inphinit [project_name]
  6. Install in Unix-like:
    cd /var/www/
    php composer.phar create-project inphinit/inphinit [project_name]
  7. Or (if no using Apache)
    cd /home/
    php composer.phar create-project inphinit/inphinit [project_name]
  8. 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.19 --recurse-submodules https://github.com/inphinit/inphinit.git [project_name]
    cd [project_name]

Note: Don't use composer dev-master (eg. create-project 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

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

PHP built-in web server in Windows

  1. Navigate with explorer.exe to project folder
  2. Find and edit server.bat, change php.exe path and php.ini for your php path:
    set PHP_BIN="C:\php\php.exe"
    set PHP_INI="C:\php\php.ini"
    set HOST_PORT=9000
  3. Save the edition and run server.bat
  4. Open webbrowser and navigate to http://localhost:9000

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

  1. If using Linux or macOS navigate to project folder and run using terminal:
    cd /home/[project_name]/
    php -S localhost:9000 system/boot/server.php
  2. Open web-browser and navigate to http://localhost:9000
  3. Or edit server
    #!/bin/bash
    PHP_BIN="/usr/bin/php"
    PHP_INI="/etc/php.ini"
    HOST_PORT=9000
  4. Save edition and run ./server

Routing

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

    Route::set('GET', '/foo', 'MyController:action');
  2. In [project_name]/system/application/Controller/ folder create an file with this name MyController.php (case sensitive)

  3. Put this content:

    <?php
    namespace Controller;
    
    use Inphinit\Viewing\View;
    
    class MyController
    {
        public function action()
        {
            $data = array( 'foo' => 'Hello', 'Baz' => 'World!' );
            View::render('myview', $data);
        }
    }
  4. In [project_name]/system/application/View/ create file with this name myview.php (case sensitive) and put:

    <p><?php echo $foo, ' ', $baz; ?></p>
  5. 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:

IIS Express

Installing in IIS Express:

  • Navigate to %USERPROFILE%\Documents\IISExpress\config
  • 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:\PHP\php-cgi.exe"
                    resourceType="Either" />
            </handlers>
        </system.webServer>
    </location>
  • Restart IIS
  • Copy contents in %USERPROFILE%\Documents\My Web Sites\WebSite1
  • 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%\System32\inetsrv\config\
  • 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:\php\php-cgi.exe"
            monitorChangesTo="C:\php\php.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:\php\php-cgi.exe"
            resourceType="Either" />

Inphinit PHP framework's Projects

framework icon framework

PHP microframework, routes, controllers and views

inphinit icon inphinit

👽 PHP web application using Inphinit framework, for PHP 5.3 to PHP 8

snippets.css icon snippets.css

Samples of html and css useful and independent of lins and toolkits, totally separate.

teeny icon teeny

A teeny route system PHP 5.3 to PHP 8

teeny.py icon teeny.py

A teeny route system for Python, with support for WSGI and http.server (Lib/http/server.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.