Deployment
Introduction
When you're prepared to deploy your Dreamfork application to production, there are several crucial steps you can take to ensure optimal performance. In this document, we'll outline some key initial measures to ensure a successful deployment of your Dreamfork application.
Server Requirements
The Dreamfork framework has specific system requirements. Please make sure that your web server meets the following minimum PHP version and includes the required extensions:
- PHP >= 8.1
- Ctype PHP Extension
- cURL PHP Extension
- DOM PHP Extension
- Fileinfo PHP Extension
- Filter PHP Extension
- Hash PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PCRE PHP Extension
- PDO PHP Extension
- Session PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Server Configuration
Nginx
When deploying your application on a server running Nginx, you can utilize the following configuration file as a basis for setting up your web server. It is important to customize this file according to your server's specific configuration.
Ensure, similar to the configuration provided below, that your web server routes all requests to the public/index.php file of your application. Avoid moving the index.php file to your project's root, as serving the application from the project root could expose sensitive configuration files to the public Internet:
server {
listen 80;
listen [::]:80;
server_name example.com;
root /srv/example.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Web Hosting
When using web hosting services and lacking access to configure Nginx or Apache, manual deployment of the application is possible. Place all application files in the main directory of your domain. Then, move the public folder to a subdirectory, which might be either public_html or private_html depending on your server's settings. Subsequently, in the public/index.php file, adjust all paths to point to the relevant application files located in the main directory. Ensure that access to these files is restricted from the browser user's perspective.
This way, the application will be accessible through the URL example.com/public/ for users. If you want the application URL to be without the folder name, you can extract the files from the public folder and place them directly in the public_html or private_html folder.
Optimization
When deploying your application, it is recommended to transfer all application files to the server, excluding folders like vendor, files from storage/logs, and files from storage/framework/views. This helps speed up the deployment process and reduces the potential for issues. After uploading the application, ensure to optimize Composer's class autoloader map for efficient class loading:
composer install --optimize-autoloader --no-dev
This command will optimize the autoloader and exclude development dependencies, ensuring a smoother and faster production deployment. Remember to configure the .env configuration file correctly by adjusting the values to fit the production environment
If Composer isn't accessible on your server, manual transfer of the
vendorfolder is possible, but strongly discouraged due to potential compatibility issues. Installing Composer on the server and runningcomposer installis the recommended approach for proper package management.
Debug Mode
The debug option in your config/app.php configuration file controls the amount of information displayed to users in the event of an error. By default, this option aligns with the value of the APP_DEBUG environment variable stored in your application's .env file.
For the production environment, it's crucial to set this value to false. Enabling
APP_DEBUGin production poses a risk of exposing sensitive configuration details to end users of your application.