2017 © Pedro Peláez
 

project app

Linna Application

image

linna/app

Linna Application

  • Saturday, July 28, 2018
  • by s3b4stian
  • Repository
  • 1 Watchers
  • 3 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 21 Versions
  • 0 % Grown

The README.md

Linna Logo

br/, (*1)

Linna dotenv Logo

br/, (*2)

[![Tests](https://github.com/linna/app/actions/workflows/tests.yml/badge.svg)](https://github.com/linna/app/actions/workflows/tests.yml) [![PDS Skeleton](https://img.shields.io/badge/pds-skeleton-blue.svg?style=flat)](https://github.com/php-pds/skeleton) [![PHP 8.1](https://img.shields.io/badge/PHP-8.1-8892BF.svg)](http://php.net)

About

Application Skeleton for Linna framework, (*3)

Actual stable environment

  • app 0.16.0
  • framework 0.27.0
  • auth-mapper-* 0.2.0

Index

  1. Requirements
  2. Installation
  3. Before first run
  4. Url rewriting
  5. Dot env file

Requirements

Note: App was only tested under Linux with Apache web server with default php.ini, (*4)

Installation

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

With composer, (*6)

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, (*7)

After, run composer dump-autoload for optimize file autoloading, (*8)

composer dump-autoload --optimize

Before first run

Change config in config.php file placed in /var/www/html/app/config directory., (*9)

Protocol and app dir config

$options = [

    'app' => [
        //protocol utilized [http://, https://]
        //default value set automatically
        'protocol'     => REQUEST_SCHEME.'://',
        //folder of the app, if app isn't in the web server root add a
        //directory (/app, /other/app) else insert a / (slash) as value
        //default value [/app]
        'subFolder'    => '/app',
        //public folder of the app, starting from web server root
        //default value [/app/public]
        'publicFolder' => '/app/public',
        //.env file position, remember to add ../ if don't use an absolute path
        'envFile'      => '../.env',
        //name of the fallback route, indicate the path when router return a NullRoute
        //default /error/404
        'onNullRoute'  => '/error/404'
    ],

    //other options
];

Router config

$options = [

    //other options

    'router' => [
        //must be equal to app.subFolder, it represents the part of the path
        //that the router ignore when check a route. Example '/app/user/delete/5'
        //become '/user/delete/5' where the router subtract the basePath
        //default [/app]
        'basePath'             => '/app',
        //url rewriting
        //default [true]
        'rewriteMode'          => true,
        //part of the url that the router ignore when url rewriting is off
        'rewriteModeOffRouter' => '/index.php?',
    ],

    //other options
];

Url rewriting

If you enable the option of the router named rewriteMode in config.php, need to configure your virtual host/server block., (*10)

Apache Virtual Host config for mod_rewrite

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/, (*11)

<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>

Apache .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., (*12)

Create .htaccess file in app/ directory with this content:, (*13)

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

Create .htaccess file in app/public/ directory with this content:, (*14)

# 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]

Nginx

For Nginx Server Blocks config please see:
https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/, (*15)

Setting url rewrite with Nginx is simpler than Apache counterpart, add try_files $uri $uri/ /index.php?$args; to location block:, (*16)

server {

    # Other directives

    location / {
        # Url rewrite
        # Add line blow to location block for enable url rewriting
        try_files $uri $uri/ /index.php?$args;
    }

    # Other directives
}

Dot env file

With composer installation, a .env file is created into app root directory and it could be used for declaring default environment variables., (*17)

.env file content look like this:, (*18)

# Session
session.name   = linna_session
session.expire = 1800

## Pdo Mysql
pdo_mysql.user     = root
pdo_mysql.password =

## Mysqli
#mysqli.host     = 127.0.0.1
#mysqli.user     = root
#mysqli.password =
#mysqli.database = linna_db
#mysqli.port     = 3306

## MongoDB
#mongo_db.uri = mongodb://localhost:27017

## Memcached
#memcached.host = localhost
#memcached.port = 11211

.env file valid keys:, (*19)

session.name
session.expire

pdo_mysql.dsn
pdo_mysql.user
pdo_mysql.password

pdo_pgsql.dsn
pdo_pgsql.user
pdo_pgsql.password

mysqli.host
mysqli.user
mysqli.password
mysqli.database
mysqli.port

mongo_db.uri

memcached.host
memcached.port

Values declared in the file will overwrite config.php values., (*20)

Position of .env file could be changed editing envFile value., (*21)

$options = [

    'app' => [
        //other app options
        'envFile'           => '../.env'
    ],

    //other options
];

If you do not want use .env file can delete it., (*22)

The Versions

28/07 2018

dev-master

9999999-dev https://github.com/linna/app

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

24/10 2017

v0.12.0

0.12.0.0 https://github.com/linna/app

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

04/10 2017

v0.11.0

0.11.0.0 https://github.com/linna/app

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

25/07 2017

v0.10.1

0.10.1.0 https://github.com/linna/app

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

17/07 2017

v0.10.0

0.10.0.0 https://github.com/linna/app

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

24/06 2017

v0.9.0

0.9.0.0

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton mvc application learning

01/06 2017

v0.8.0

0.8.0.0

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton application learning mvc-application

28/03 2017

v0.7.0

0.7.0.0

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton application learning mvc-application

28/02 2017

v0.6.1

0.6.1.0

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton application learning mvc-application

26/02 2017

v0.6.0

0.6.0.0

Linna Application

  Sources   Download

MIT

The Requires

 

php skeleton application learning mvc-application

08/01 2017

v0.5.1

0.5.1.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

04/01 2017

v0.5.0

0.5.0.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

14/11 2016

v0.4.0

0.4.0.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

07/11 2016

v0.3.3

0.3.3.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

24/10 2016

v0.3.2

0.3.2.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

20/10 2016

v0.3.1

0.3.1.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

19/09 2016

v0.3.0

0.3.0.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

14/09 2016

v0.2.2

0.2.2.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

10/09 2016

v0.2.1

0.2.1.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

10/09 2016

v0.2.0

0.2.0.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn

01/09 2016

v0.1.0

0.1.0.0

Linna Application Skeleton

  Sources   Download

MIT

The Requires

 

framework php skeleton app mvc learn