Installation

To install PHP libraries, the composer package must be installed on your computer.

Requirements

Before installation, please install the following components in your working environment.

  • Composer
  • Php 8.0 or higher versions
  • Apache 2 or higher
  • Apache Mod Rewrite
  • Redis Server
  • Php Redis Extension

To create an Olobase project backend application, first copy the clone link from github php repository and then paste it into your console along with the following git clone command.

git clone --branch 1.3.0 [email protected]:olomadev/olobase-skeleton-php.git example-php

Install composer packages.

/var/www/example-php$ composer install

Give 777 permision for /data/tmp cache folder.

chmod 777 -R /var/www/example-php/data/tmp

Useful Resources About Mezzio

Olobase uses the Mezzio Framework in the backend. If you would like to get more detailed information about the Mezzio framework, you can take a look at the resources below.

Source Type Url Description
Documents https://docs.mezzio.dev/ Mezzio official documentation web address.
Installation https://matthewsetter.com/how-to-create-a-mezzio-application/ Blog address written by the creator of Mezzio and containing extensive information about Mezzio installation.

Apache2 Configuration

Enable Apache mod_rewrite plugin.

sudo a2enmod rewrite

The AllowOverride option for directories in the apache2.conf file must be All.

vim /etc/apache2/apache2.conf

Change this option from the default None to All.

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Create a hosts file.

cd /etc/apache2/sites-available
cp 00-default.conf example.local.conf
vim example.local.conf

In your Apache host file, the DocumentRoot configuration must be set to the yourproject/public/ folder. It is recommended to set DirectoryIndex to index.php. ServerName is set to example.local in this example.

<VirtualHost *:80>

    SetEnv "APP_ENV" "local"
    ServerName example.local
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/olobase-skeleton-php/public/
    DirectoryIndex index.php

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save your vhost file and restart the apache server.

a2ensite example.local.conf
sudo service apache2 restart

.htaccess

Configuration requires the .htaccess file as follows. This file is located in the /public folder.

# Disable directory indexing
# Options -Indexes
# Options +FollowSymLinks
# Options -MultiViews

php_value post_max_size 10M
php_value upload_max_filesize 10M

RewriteEngine On
#
# Redirect www to non-www
#
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# The following rule allows authentication to work with fast-cgi
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.

RewriteCond %{REQUEST_URI} !/api/
RewriteRule ^(.*)$ %{ENV:BASE}index.html [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
This documents is available for subscribers only

Get Full Accesss