Hi! I'm Dards a Full Stack Web Developer.

Polymath is a person whose expertise spans a significant number of different subject areas

Deploying Laravel on VPS.

go to folder on the same level of public_html and create new folder for your project and upload all the laravel file exect the public folder

Upload the contents of the public directory from your project into the public_html directory on your web server (i.e. /home/accountname/public_html/) .

Modify the laravel/bootstrap/app.php file to set the public.path value. Add the following block of code to the file before the “Bind Important Interfaces” block. Adjust the path as needed if you are deploying the application on a subdomain.

$app->bind('path.public', function ()
    return __DIR__.'/../../public_html';

4. Modify the public_html/index.php file to adjust the paths to point to the directory containing the Laravel core files. Refer to the following code block. Again, adjust the paths as needed if you are deploying the application on a subdomain.

require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

note: if open_basedir error: edit /home/admn/conf/web/[webdomain].httpd.conf and add the path of laravel app folder to the open_basedir value


NOTE: if you are cloning your existing app, you need to generate new app key

$  php artisan key:generate

Automatically generate slug when saving model.

This snippet code automatically generate a url-friendly slug where spaces are converted into dash character for website address, normally use in some blog page of the website

class Item extends Model
public static function boot()
static::saving(function ($model) {
$model->slug = str_slug($model->name);
Slug is a Laravel helper that converts a given string into a dash separated string


The str_slug function generates a URL friendly "slug" from the given string:

$title = str_slug('Laravel 5 Framework', '-');