Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Install Laravel 5.8 on a Server & Make Your App More Powerful

May 30, 2019

8 Min Read
install laravel
Reading Time: 8 minutes

Laravel is the most advanced PHP framework available for developers. The framework gets an update every year with the release of new version. This year’s release of Laravel 5.8 doesn’t disappoint the developers either, as the latest version integrates some new features as well as upgradation of some old features.

Laravel 5.8 Features

The latest features in Laravel 5.8 are amazing and make the framework more powerful and secure. These features help optimize Laravel website performance from the core.

After installing Laravel 5.8, here’s what you will get:

  • Update Email Validation Rule
  • Dotenv 3.0
  • Deprecated String and Array Helpers Functions
  • Blade Template File Path in Compiled file
  • Cache TTL in Seconds Change
  • New Method firstWhere in Collection
  • Unquoted MySQL JSON Values in Database

Update Email Validation

The email validation rules are already present in Laravel. However, Laravel 5.8 now features international charters that you must check in email address. It means that email validation will now check whether the email fulfills RFC5630 compliant rules or not.

For example, if your Laravel project contains the following email validation code:

$request->validate([

'email' => 'email',

]);

The email validation process for the email such as axy@abcd.se will fail in Laravel 5.7. However with the new updates in Laravel 5.8, it will get pass successfully.

Dotenv 3.0

Laravel 5.8 supports new Dotenv 3.0 to manage .env environment of the project.

The key feature in Dotenv 3.0 is its support for multiline strings and white spaces at the end of the strings in .env file. For example:

DEVELOPMENT_APP_KEY="specialstringforthisapplication"

Other features included are:

  1. More flexibility in terms of which parts of the environment you will want to read and modify
  2. First-class support for multiline variables.
  3. No more trimming of values, you get them exactly as they are.
  4. Accepts the list of path to find .env file, rather than working on a single path.
  5. Stronger validation of variable names to avoid silent failures or obscure errors.

In Laravel 5.7, it only returns specialstringfor. Meanwhile, in Laravel 5.8, you can parse the whole specialstringforthisapp. It will also neglect the added spaces at the end of the string, which were previously stripped from the environment variables.

Powerful Laravel Hosting For All Your Needs

Grow your Laravel app with our feature-rich managed hosting

Deprecated String and Array Helpers Functions

In Laravel 5.8, there are no string and array helpers available. Instead, you will have to use the Arr:: and Str:: facades. Meanwhile, if you don’t want to re-work on the existing code, you can use certain packages to maintain the existing functionality.

You must replace an existing array_ function such as:

function array_add($array, $key, $value)

with:

Arr::add($array, $key, $value)

Similarly string helper functions such as:

function str_contains($haystack, $needles)

Should be replaced with:

Str::contains($haystack, $needles);

In fact, if you check the Laravel 5.8 code for array_* and str_* global helpers, you’ll see they are already using the facade version.

Carbon 2.0 Support

The new version of Carbon date manipulation library(2.0), is now supported in Laravel 5.8 to facilitate the developers for handling relevant operations.

Pheanstalk 4.0 Support

Laravel 5.8 now supports Pheanstalk 4.0. If you are using the older Pheanstalk library version in your application, do upgrade to the latest version(4.0) using Composer.

Blade Template File Path in Compiled file

Though, we all know that Laravel compiles the blade file but somehow doesn’t provides the path of it. Laravel 5.8, comes up with the solution of the problem.

In Laravel 5.8, there is a specific  path for the blade template file, as shown in the example:

<?php /* /var/www/me/5.8/blog/resources/views/welcome.blade.php */ ?>

<!doctype html>

<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">

   <head>

       <meta charset="utf-8">

       <meta name="viewport" content="width=device-width, initial-scale=1">

       <title>Laravel</title>

       <!-- Fonts -->

       <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">

Laravel Error Page

Laravel 5.8 comes with new error pages that contain minimalist design intended to be fit for range of websites. So, the web apps don’t require re-designing as these error pages fit right according to them.

Cache TTL in Seconds Change

If your application is using caching function in Laravel 5.8, then take note that passing an integer to the cache function will apply the time to get live in seconds, unlike of Laravel 5.7 which take minutes.

Cache::put('foo', 'bar', 15);

Same with these putMany(), add() and remember().

It will store the value for 15 minutes in Laravel 5.7 and 30 seconds in Laravel 5.8. A simple yet a very contrasting difference!

You Might Also Like: Integrate Laravel Cache & Skyrocket Your Web App Performance

New Method firstWhere in Collection

Laravel 5.8 introduces a new function called firstWhere() integrated with collection object. Instead of using first(), you can get single object using the firstWhere() method.

Let’s see an example:

$collection = collect([

   ['name' => 'Hardik', 'age' => 25],

   ['name' => 'Vimal', 'age' => 24],

   ['name' => 'Harshad', 'age' => 23],

]);

$collection->firstWhere('name', 'Vimal');

// ['name' => 'Vimal', 'age' => 24]

Unquoted MySQL JSON Values in Database

In Laravel 5.7, the JSON returns the values stored in MySQL and MariaDB database columns in wrapped double quotes, whereas, Laravel 5.8 returns the same values in clean strings.

Here is an example from the Laravel upgrade guide which illustrates the change:

$value = DB::table('users')->value('options->language');

dump($value);

// Laravel 5.7…

'"en"'

// Laravel 5.8…

'En'

Nexmo and Slack Notification channels:

The notification channels of Nexmo and Slack are removed from the main Laravel project and are extracted into the first party packages.

To continue using Slack or Nexmo functionality in your project, you’ll need to use:

composer require laravel/nexmo-notification-channel

composer require laravel/slack-notification-channel

You Might Also Like: Laravel Notification System On Slack And Email

Upgrade Process From Laravel 5.x to Laravel 5.8

To upgrade Laravel 5.x to Laravel 5.8, you need at least one hour for the estimated changes mentioned in Laravel Doc. To start installing Laravel 5.8, first update your framework dependency to 5.8 in your composer.json file.

  • The environment Method
  • Authentication
  • Cache
  • Collections
  • Database
  • Eloquent
  • View
  • Validation
  • Notifications

Laravel 5.8 install on Server (Local host)

To install Laravel 5.8 from the scratch, you will need the following server requirements:

  1. PHP >= 7.1.3
  2. Composer
  3. Xampp / Wamp

Laravel uses composer files to manage its dependencies. To begin installing Laravel with composer, you have to first install the composer in your local machine as shown in the image below:

Once the installation of Laravel Composer is complete, you must launch the Laravel 5.8 app on the server by entering following command:

composer create-project --prefer-dist laravel/laravel Cloudways

Starting Laravel Server

If you have installed PHP application on a local host, and you want its built-in development server to host the application, you can use the Laravel Artisan command. This command will help starting Laravel server at http://localhost:8000.

php artisan serve

Now, you can open your application URL and can see the Laravel page in it. You have successfully installed Laravel 5.8 on your local server.

Install Laravel on Cloudways

Cloudways provides managed cloud hosting services on top of the rank Cloud servers including AWS, DigitalOcean, Linode and others. Its flawless features make it one of the best Laravel hosting service providers today.

Installing Laravel on Cloudways doesn’t require any prerequisite steps like Laravel composer installation, PHP setup etc. As the platform provides simple one-click installation of Laravel. Just select your server requirements and click on Laravel’s latest version, your application will be ready within minutes with all the initial framework settings.

Performance

Cloudways provides a complete stack of web tools called Thunderstack, which helps developers in optimizing Laravel website speed and performance. The stack consists of different web tools including Memcached, Redis, Varnish, Nginx, PHP-FPM and others. The primary purpose of integrating all these tools in a single stack is to give developers the ease to find all web tools at one place, thus helping them get fast web and content delivery speed.

Security

To enhance website security, Cloudways provides one-click SSL certificate installation facility to ensure data security from malicious web attacks. Meanwhile the auto healing servers ensure the safety of your website in case of any accidental failure or unwanted letdown.

The IP whitelisting feature allows you to set up secure connections with unrestricted SSH and SFTP access.

Steps to install Laravel 5.8 on Cloudways

The following Laravel installation tutorial shows how easy it is to setup Laravel on Cloudways. To begin installing Laravel on server, you must first select your PHP server and application according to your project requirements. Select server size as per your website traffic and location according to your preferred region.

After completing all these steps, you can finally go to the application tab where you will find your newly installed Laravel PHP application. Click on it to find further details inside:

SSH Terminal

Now, to install Laravel 5.8, you must open the SSH terminal to run the composer command. You can either use Putty terminal or Cloudways SSH terminal for better results.

Let’s start with Putty, go to the application public_html folder and type the following Laravel installation command:

Now, paste the following command to begin installing Laravel 5.8 on your Cloudways server:

composer create-project --prefer-dist laravel/laravel blog

Laravel-5.8

Once you have executed the above-mentioned command, go to your application path “url/Cloudways/public”, where you will see the following screen.

Laravel 5.8 New Features [Infographic]

laravel 5.8 infographic

Q: How to disable Xdebug during Laravel installation via composer?

A: To streamline Laravel app installation, you can easily disable Xdebug from the console’s php.ini file. Here’s how to do it using composer:
# Set xdebug autostart to false
xdebug.remote_autostart=0
xdebug.remote_enable=0
# Disable your profiller
xdebug.profiler_enable=0

Q: Where to find the Laravel installation folder?

A: Once finishing the installation with composer, you can find the newly created Laravel folder inside the xampp\htdocs folder. First cd into the xampp\htdocs folder and then use ‘cd myApp’ to go inside your newly installed Laravel folder.

Q: How to install Laravel in PHP server without composer?

A: To install Laravel without composer, you have to once run composer install/update command, which will download all the libraries locally. You can then upload all those files manually to the server and right after your project will have all the dependencies available on server.

Q: How to upload Laravel project to the server?

A: Simply upload all your project files into the root directory of your domain, while upload the contents of public into the public_html folder. This is one of the easiest way of uploading a Laravel project on the web server.

Final Words

This article provides our readers with a brief demonstration about how to install Laravel 5.8 and its new updated features. The framework is now more powerful and developer-centric as compared to the older versions. That is why, the developers’ community seems really happy with the new features.

The article provides you with comprehensive information regarding new Laravel 5.8 features and how to use them in the project. If you still have some more questions regarding Laravel 5.8, you can always use the comments section to post your comments and queries.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Launch Laravel apps with 1-Click Install. Painless Server Management

Deploy your apps on optimized Laravel hosting servers.

Pardeep Kumar

Pardeep is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He love to work on Open source platform , Frameworks and working on new ideas. You can email him at pardeep.kumar@cloudways.com

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!