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 Vuexy, 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
βββ π .styleci.yml
βββ π artisan
βββ π composer.json
βββ π package.json
βββ π phpunit.xml
βββ π vite.config.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));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../laravel/storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../laravel/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
//--- binding your app ---//
$app->bind('path.public', function() {
return base_path('/../public_html/demo/');
});
$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.<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($maintenance = __DIR__.'/../../laravel/storage/framework/maintenance.php')) {
require $maintenance;
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
require __DIR__.'/../../laravel/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
//--- binding your app ---//
$app->bind('path.public', function() {
return base_path('/../public_html/demo/');
});
$kernel = $app->make(Kernel::class);
$response = $kernel->handle(
$request = Request::capture()
)->send();
$kernel->terminate($request, $response);