Objective

Main objective of this blog post is to give you an idea about how to Upgrading From Laravel 4.2 to 5 in Web.

 

 

Step 1 Introduction

Taylor Otwell once said that Laravel 4.3 would be renamed to Laravel 5 Since that announcement the excitement for the upcoming version has been building and it turned into almost two dozen new features to help developers be more productive.

Laravel’s new upgrade packs a lots of new features, but also keeps the parts that made Laravel wildly successful.

Laravel 5 comes with an overhaul of the new directory structure. The app directory now only has the application logic. If app only contains application logic what about, everything else?

Directories like tests, storage, config and database have been moved to the root. The views and lang directories have been placed in a new resources directory (in root)

 

Step 2 Laravel’s new Directory Structure:

  • App
    1. Console
    2. Http
      • Requests
      • Filters
      • Controllers
    3. Providers
  • Bootstrap
  • Config
  • Database
    1. Migrations
    2. Seeds
  • Public
  • Resources
    1. Lang
    2. Views
  • Storage
    1. Cache
    2. Logs
    3. Meta
    4. Sessions
    5. Views
    6. Work
 

Step 3 Upgrading Process

  1. Fresh Install ->Then Migrate The recommended method of upgrading is to create a new Laravel 5.0 install and then to copy your 4.2 project's unique application files into the new application. This would include assets, Artisan commands, routes, eloquent models, controllers and other code specific to your application.To start, install a new Laravel 5 application into a fresh directory.
  2. Composer Dependencies & Packages Copy every additional Composer dependencies into your 5.0 application. This includes third-party SDKs as well.Some Laravel-specific packages may not be compatible with Laravel 5 at initial release. Check the package's maintainer to determine the proper version of the package for Laravel 5. Once you have added additional Composer dependencies, run composer update.
  3. Namespacing Laravel 4.2 applications did not utilize namespacing within your application code. For example, Controllers and Eloquent models simply lived in the "global" namespace. You can simply leave these classes in the global namespace in Laravel 5 as well.
  4. Migrating Environment Variables Copy the new .env.example file to .env, which is the 5.0 equivalent of the old .env.php file. Set the appropriate values, like APP_ENV and APP_KEY, DB credentials, cache and session drivers.Copy all custom values you had in your old .env.php file and place them in both .env and .env.example.
  5. Configuration Files Laravel 5.0 no longer uses app/config/{environmentName}/ directories to provide specific configuration files for a given environment. Move any configuration values that vary by environment into .env, and then access them in your configuration files using env('key', 'default value').Set the config files in the config/ directory to represent either the values that are consistent across all of your environments, or set them to use env() to load values that vary by environment.Remember, if you add more keys to .env file, add sample values to the .env.example file as well. This will help your other team members create their own .env files.
  6. Routes Copy and paste old routes.php file into new app/Http/routes.php.
  7. Controllers Move all controllers into the app/Http/Controllers directory. Since we are not going to migrate to full namespacing in this guide, add the app/Http/Controllers directory to the classmap directive of your composer.json file. Now, you can remove the namespace from the abstract app/Http/Controllers/Controller.php base class. Verify that your migrated controllers are extending this base class.In app/Providers/RouteServiceProvider.php file, set the namespace property to null.
  8. Route Filters Copy filter bindings from app/filters.php and place them into the boot() method of app/Providers/RouteServiceProvider.php. Add use Illuminate\Support\Facades\Route; in the app/Providers/RouteServiceProvider.php in order to continue using the Route Facade.We don’t need to move the default Laravel 4.2 filters such as csrf and auth; they're all here, but as middleware. Edit the routes and controllers that reference the old default filtersExample:['before' => 'auth'] and change them to reference the new middleware ['middleware' => 'auth'].Filters are not removed in Laravel 5. You can still bind and use your own custom filters using before and after.
  9. Global CSRF CSRF protection is enabled on all routes. If you would like to disable this, or only manually enable it on certain routes, remove this line from App\Http\Kernel's middleware array:'App\Http\Middleware\VerifyCsrfToken',If you want to use it elsewhere, add this line to $routeMiddleware:'csrf' => 'App\Http\Middleware\VerifyCsrfToken'Now add the middleware to individual routes / controllers using ['middleware' => 'csrf'] on the route.
  10. Artisan Commands Move all the command classes from old app/commands directory to the new app/Console/Commands directory. Now, add the app/Console/Commands directory to the classmap directive of your composer.json file.Next, copy your list of Artisan commands from start/artisan.php into the command array of the app/Console/Kernel.php file.
  11. Database Migrations & Seeds Move all the migration classes from the old app/database/migrations directory to the new database/migrations. All of your seeds should be moved from app/database/seeds to database/seeds.

I hope this blog post will help you to Configure Laravel 5 in Mac OS X in Web. Let me know in comment if you have any questions regarding Web. I will reply you ASAP.

Got an Idea of Web Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Web Development Company in India.

An entrepreneur who has founded 2 flourishing software firms in 7 years, Tejas is keen to understand everything about gaming - from the business dynamics to awesome designs to gamer psychology. As the founder-CEO of a company that has released some very successful games, he knows a thing or two about gaming. He shares his knowledge through blogs and talks that he gets invited to.