We are going to discuss basic changes in our template before deploying it.
Laravel deployment differs from server to server and also if you deploy on root domain or subdomains. There are no special steps of deployment specifically for Materio, it's the same for all the projects built with Laravel.
There should be some minor changes when you deploy your project on root folder or sub folder.
.env
variables value:APP_ENV=production
APP_DEBUG=false
yarn build
We have two folders on the server.
We move all public files inside the public_html
folder, and the rest of our application resides in the laravel
folder.
π public_html/ -> (folder for public accessible)
βββπ assets
β βββ π audio
β βββ π img
β βββ π json
β βββ π svg
βββπ build
β βββ π assets
β βββ π index.html
β βββ π manifest.json
βββ π .htaccess
βββ π favicon.ico
βββ π index.php
βββ π robots.txt
πlaravel/ -> (folder where laravel live)
βββ π app
βββ π bootstrap
βββ π config
βββ π database
βββ π lang
βββ π resources
βββ π routes
βββ π storage
βββ π tests
βββ π vendor
βββ π .editorconfig
βββ π .env
βββ π .gitattributes
βββ π .gitignore
βββ π artisan
βββ π composer.json
βββ π package.json
βββ π phpunit.xml
βββ π vite.config.js
βββ π vite.icons.plugin.js
index.php
file in the public_html folder. Also, we have to bind
the document root to the current file path, where index.php
exists.<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
if (file_exists($maintenance = __DIR__.'/../laravel/storage/framework/maintenance.php')) {
require $maintenance;
}
require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
$app->bind('path.public', function() {
return base_path('/../public_html');
});
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);
Mainly, subfolder deployment means deploying your project inside some nested folder on server. For example:
Public_html -> your_folder -> another_folder -> your_project_goes_here
step 1
and step 2
of the above root deployment steps.index.php
file.if (file_exists($maintenance = __DIR__.'/../../laravel/storage/framework/maintenance.php')) {
require $maintenance;
}
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
$app->bind('path.public', function() {
return base_path('/../public_html/your_folder');
});