7 TIPS TO BUILT SUCCESSFUL LARAVEL APPLICATION

Rahul Chauhan - Laravel Developer

7 TIPS TO BUILT SUCCESSFUL LARAVEL APPLICATION

Laravel Tips & Trends

Started in 2011, Laravel framework community has grown and now it is the best PHP framework in 2017. From simple web app too complex API's, Laravel is a perfect PHP framework which can fulfill creation of all complex features. With its simple elegant syntax building applications, it feels like having fun. It provides a set of libraries which makes it easy to build a web app using well structured and beautiful code. Database migrations, powerful Active-Record implementation (Eloquent), powerful unit testing, routing, highly tested HTTP layer and much more feature Laravel framework is a power-packed PHP framework.

You can even refer this article before you a hire Laravel developer for development of your application, just to check the capability of the developer.

Here are some tips for you so you can develop better applications.

1. Enhance Artisan Command Uses: Laravel has a unique tool named Artisan command which is helpful to boost performance.  If you are using a lot of routes and configuration, then you should create a cache as a plain array so your application loads faster.

- php artisan config:cache

- php artisan route:cache

- php artisan optimize --force

When you change config or route file, don’t forget to re-run these commands or Laravel will not handle changes that you’ve made. By running these commands, we also limit locations, settings, and user data.  So when you change data, make sure you invalidate the cache.

2. Remove Unused Service:  If you are not using service, don't load that service in your config file. But after commenting that service code makes sure that your app works properly.

3. Minimize the Use of Plugins:  Plugins reduce our development time by adding more functionality to our project. But when we add a plugin, we add some files and libraries to that project. Use a plugin when it is required. Cutting down your composer.json file will cut the dependencies that are loading.

4. Profiling Your Queries: Ever wondered what happens when you execute a query? To know install a Laravel package profiler from https://github.com/barryvdh/laravel- debugbar.
Once you add this, it will add a console where you can view all SQL queries issued for that page.

5. Use soft deletes: Delete operation shouldn’t be a straight delete operation that deletes permanently because once a user deletes that the record, he cannot get it back. If you want to give this permission to your user, use SOFT delete. Enable soft delete in your models by protected $softDelete = true; property. Moreover, you are required to add a column deleted_at using DateTime property.

6. Optimize Memory: If you have a million records, then these operations are very heavy for RAM. Use Eloquent's chunk method to handle this thing.

Apphouse::chunk(200, function($res)

{

            foreach ($res  as $rs)

            {

                        // operations here...

            }

});

Here 1st parameter defines size and 2nd parameter is the closure that defines what to do with that chunk.

7. Protect App from bots and spammers: When one website pretends to be some other website this concept is known as Cross-Site Request Forgery (CSRF). By this, someone can hijack users’ access to your web. In Laravel framework, you can protect all inbound routes.

Thanks for reading!


Leave us a comment