Installation

Last updated: Wed, 12 Sep 2018 09:48

This page describe the default installation for the most of HTTP projects. But you can use Berlioz Framework for CLI projects for example, go to advanced usage page to know more.

Berlioz Framework

Installation of Berlioz Framework must be done by Composer, it's the recommended installation.

composer create-project berlioz/berlioz --remove-vcs

You can specify the version to composer:

composer create-project berlioz/berlioz 1.0 --remove-vcs

Info:

Option --remove-vcs remove automatically the .git directory from the default project.

HTTP server

To run the application, your HTTP server must be pointed on public directory.

Apache server

Apache is the most popular web server.

For Apache version >= 2.4:

<VirtualHost *:80>
    ServerName www.berlioz-framework.com
    DocumentRoot "/path/to/my-project/public"

    <Directory "/path/to/my-project/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

For Apache version < 2.4:

<VirtualHost *:80>
    ServerName www.berlioz-framework.com
    DocumentRoot "/path/to/my-project/public"

    <Directory "/path/to/my-project/public">
        AllowOverride All
        Allow from all
    </Directory>
</VirtualHost>

Warning:

Needs to enable the module mod_rewrite on Apache.

Cf. Apache documentation for installation.

If you want increase the performances of your server, it's to disable support of .htaccess files.

For that, you must specify to Apache the fallback resource and disable option AllowOverride:

<Directory "/path/to/my-project/public">
    AllowOverride None
    FallbackResource /app.php
    # ...
</Directory>

Nginx

Nginx is a high performance web server.

To run PHP application with Nginx, you need to use PHP FPM (FastCGI Process Manager).

server {
    server_name www.berlioz-framework.com;
    root /path/to/my-project/public;

    # Test existent of file before redirect to fallback file: app.php
    location / {
        try_files $uri /app.php$is_args$args;
    }

    # Configuration for app.php file calls
    location ~ ^/app\.php(/|$) {
        # FastCGI configuration
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # FastCGI parameters to give directory and script infos
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        # To do not use app.php file for routes
        internal;
    }

    # To deny all others PHP files
    location ~ \.php$ {
        return 404;
    }
}

PHP HTTP server

If you want test application without Web Server to installed, you can use built-in web server.

To start server:

cd /path/of/project
cd public
php -S localhost:8000 app.php

In your web browser, go to the url: http://localhost:8000, you will see your project!

Warning:

The PHP built-in web server is only for development environment. Do not use it in production!

Test first page

Go to in your favorite browser, and try to go to your page, in your example: www.berlioz-framework.com.

If everything ok, you will see this screen:

First page

You can also see on this first page, the debug console of Berlioz. If you click on, you will see the debug detail:

Debug