Installation: Creating Project and Virtual Host

To install this framework and have a fully working site you need following prerequisites:

and familiarize yourself with these concepts:

Installing Framework

Once installation requirements are met, open console and run this command:

composer create-project lucinda/framework DOCUMENT_ROOT/SITE_NAME

This will install framework and all its dependencies in folder: DOCUMENT_ROOT/SITE_NAME. Now to complete installation you need to create a DOMAIN_NAME that points to that location!

Bootstrapping

Bootstrapping is the process by which all requests to DOMAIN_NAME are routed to DOCUMENT_ROOT/SITE_NAME. In Lucinda projects (and pretty much every other framework), it is done according to following rules:

All of this is done in three steps, regardless of operating system:

After you're all done, simply restart web server and go to http://DOMAIN_NAME and follow steps described there.

Setting Hosts File

Go to /etc/hosts @ Mac/Linux or C:\Windows\System32\drivers\etc\hosts @ Windows and add this line:

127.0.0.1 DOMAIN_NAME

This will resolve all internal requests to DOMAIN_NAME (regardless of protocol) to be handled by localhost.

Creating a Virtual Host

Now that you have resolved requests to localhost, you must inform web server to make http/https requests to DOMAIN_NAME point to files in DOCUMENT_ROOT/SITE_NAME folder. This process reques creating a virtual host.

Setting Apache2 VirtualHost

After you've made sure mod_rewrite is enabled, open general vhosts configuration file or create a specific vhost file (eg: /etc/apache2/sites_available/YOUR_HOST_NAME.conf) then write:

<VirtualHost *:80> # sets site domain name (eg: www.testing.local) ServerName DOMAIN_NAME # sets location of site on disk (eg: /var/www/html/testing) DocumentRoot DOCUMENT_ROOT/SITE_NAME # delegates rerouting to htaccess file above <Directory DOCUMENT_ROOT/SITE_NAME> AllowOverride None Require all granted # informs Apache2 web server you are going to reroute requests RewriteEngine on # turns off directory listing Options -Indexes # makes 404 responses to public (images, js, css) files handled by web server ErrorDocument 404 default # lets web server allow Authorization request header RewriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # redirects all requests, except those pointing to public files, to bootstrap RewriteCond %{REQUEST_URI} !^/public RewriteCond %{REQUEST_URI} !^/favicon.ico RewriteRule ^(.*)$ index.php </Directory> </VirtualHost>

Now enable specific virtualhost (eg: a2ensite /etc/apache2/sites_available/YOUR_HOST_NAME.conf @ Linux), if any, and restart web server.

Setting NGINX VirtualHost

Open general vhosts configuration file or create a specific vhost file (eg: /etc/nginx/sites_available/YOUR_HOST_NAME.conf @ Linux) then write:

server { listen 80; listen [::]:80 ipv6only=on; # sets location of site on disk (eg: /var/www/html/testing) root DOCUMENT_ROOT/SITE_NAME; # sets location of bootstrap file index index; # sets site domain name (eg: www.testing.local) server_name DOMAIN_NAME; # redirects all requests, except those pointing to public files, to bootstrap location / { rewrite ^/(.*)$ /index; } location /public/ { } location /favicon.ico { } # configures PHP-FPM to handle requests location ~ \$ { try_files $uri =404; fastcgi_split_path_info ^(.+\)(/.+)$; # location of PHP-FPM socket file (eg: /var/run/php/php7.0-fpm.sock) fastcgi_pass unix:SOCKET_FILE_LOCATION; fastcgi_index index; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_ADMIN NA; fastcgi_param SERVER_SIGNATURE nginx/$nginx_version; include fastcgi_params; } }

Now enable specific virtualhost (eg: ln -s /etc/nginx/sites-available/YOUR_HOST_NAME.conf /etc/nginx/sites-enabled/ @ Linux), if any, then restart web server.

Setting Development Environment

Now that you have both hosts and virtual hosts configured, the only step left is setting development environment that must uniquely identify a machine against others running the same project. This must be done on web server directly then requires a restart.

To set development environment for Apache2, make sure mod_env is enabled then append this line inside <directory> statement @ virtual host:

SetEnv ENVIRONMENT local

To set development environment for NGINX, edit PHP-FPM configuration file (eg: /etc/php/7.2/fpm/php-fpm.conf @ Linux) then append this line:

env[ENVIRONMENT] = local

Above directives set your development environment as local (your personal workstation).

Configuring Your Project

Now that you've finished configuring web server, open your browser and visit http://DOMAIN_NAME to see a welcome page that invites you to configure your project. In order to enforce performance and modularity, project starts with MVC abilities only! To add any other run in console:

cd DOCUMENT_ROOT/SITE_NAME php configure.php project

This will prompt a step-by-step configuration guide useful to plug in features your project needs and finally build a working project in that folder!

×