← Back
emir

emir/app

Application skeleton for rapid development with Framework

View on GitHub ↗
Stars
1
Forks
0
Watchers
1
Open issues
0
Contributors
1
Language
PHP
License
MIT License
Default branch
master
Created Oct 22, 2017Updated Oct 22, 2017

Star growth

Today—
This week—
This month—

Star history will appear here once this repo has been tracked for a couple of days.

README

Linna App


Build Status Scrutinizer Code Quality StyleCI

Application Skeleton for Linna framework

Getting Started

Requirements

App was written for run with linna/framework and need PHP 7.0 or higher, was tested under Linux with Apache web server with default php.ini.

Installation

Note: Consider use of sudo command if need administrator privileges and don't forget to set proper folder permissions

With composer

cd /var/www/html
mkdir app
composer create-project --prefer-dist linna/app app

Where app is directory under webserver document root ex. /var/www/html/app

After, run composer dump-autoload for optimize file autoloading

composer dump-autoload --optimize

Before run

Change config in config.php file placed in /var/www/html/app/config directory.

Protocol and app dir

$options = [

    'app' => [
        //protocol utilized [http://, https://]
        'protocol'       => 'http://',
        //folder of the app, if app isn't in the web server root
        'subFolder'      => '/app',
        //public folder of the app
        'publicFolder'   => '/app/public',
        //define if app use routes exported in static array [true, false]
        'compiledRoutes' => false
    ],
    //other options
];

Url Rewriting

$options = [
    //other options
    'router' => [
        'basePath'              => '/app', //equal to urlSubFolder
        'badRoute'              => 'E404',
        'rewriteMode'           => true,
        'rewriteModeOffRouter'  => '/index.php?',
    ],
    //other options
];

Apache Virtual Host config for mod_rewrite

If you enable the option of the router named rewriteMode in config.php, need to add to your virtual host configuration file the following line of code.

For Apache VirtualHost config please see:
http://httpd.apache.org/docs/current/vhosts/
For Apache mod_rewrite config please see:
https://httpd.apache.org/docs/current/rewrite/

<VirtualHost *:80>

    # Other virtual host directives.

    <Directory /var/www/html/app>
        RewriteEngine on
        # Route to /app/public
        RewriteRule ^(.*)  public/$1 [L]
    </Directory>

    <Directory /var/www/html/app/public>
        # Necessary to prevent problems when using a controller named "index" and having a root index.php
        # more here: http://httpd.apache.org/docs/current/content-negotiation.html
        Options -MultiViews

        # Activates URL rewriting (like myproject.com/controller/action/1/2/3)
        RewriteEngine On

        # Prevent people from looking directly into folders
        Options -Indexes

        # If the following conditions are true, then rewrite the URL:
        # If the requested filename is not a directory,
        RewriteCond %{REQUEST_FILENAME} !-d
        # and if the requested filename is not a regular file that exists,
        RewriteCond %{REQUEST_FILENAME} !-f
        # and if the requested filename is not a symbolic link,
        RewriteCond %{REQUEST_FILENAME} !-l

        # then rewrite the URL in the following way:
        # Take the whole request filename and provide it as the value of a
        # "url" query parameter to index.php. Append any query string from
        # the original URL as further query parameters (QSA), and stop
        # processing (L).
        # https://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa
        # https://httpd.apache.org/docs/current/rewrite/flags.html#flag_l
        RewriteRule ^(.+)$ index.php [QSA,L]
    </Directory>

    # Other virtual host directives.

</VirtualHost>

.htaccess config for mod_rewrite

If you haven't access to your apache virtual host configuration, you can add .htaccess files to the app for enable mod_rewrite.

Create .htaccess file in app/ directory with this content:

RewriteEngine on
# Route to /app/public
RewriteRule ^(.*)  public/$1 [L]

Create .htaccess file in app/public/ directory with this content:

# Necessary to prevent problems when using a controller named "index" and having a root index.php
# more here: http://httpd.apache.org/docs/current/content-negotiation.html
Options -MultiViews

# Activates URL rewriting (like myproject.com/controller/action/1/2/3)
RewriteEngine On

# Prevent people from looking directly into folders
Options -Indexes

# If the following conditions are true, then rewrite the URL:
# If the requested filename is not a directory,
RewriteCond %{REQUEST_FILENAME} !-d
# and if the requested filename is not a regular file that exists,
RewriteCond %{REQUEST_FILENAME} !-f
# and if the requested filename is not a symbolic link,
RewriteCond %{REQUEST_FILENAME} !-l

# then rewrite the URL in the following way:
# Take the whole request filename and provide it as the value of a
# "url" query parameter to index.php. Append any query string from
# the original URL as further query parameters (QSA), and stop
# processing (L).
# https://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa
# https://httpd.apache.org/docs/current/rewrite/flags.html#flag_l
RewriteRule ^(.+)$ index.php [QSA,L]

Now App can be started from browser.