September 17, 2020 By Pratik And Dhaivat Category: Laravel Development

What is Laravel?

Laravel is an open-source PHP framework available free of cost intended for the development of Web Application, which follows MVC (Model-View-Controller) architecture. It comes with features such as a modular packaging system, a variety of ways to access the relational database, utilities that help in web application deployment. It’s licensed under MIT License. Laravel has seen improvements year by year, and new functionalities being implemented. The latest stable version of Laravel was released on September 8, 2020.

What is Lumen?

Lumen is a micro web framework written in PHP and created by Laravel. It’s small and works rapidly and a tiny version of the complete web application. Lumen mainly builds for microservices – small, loosely coupled components that support and expand the functionality of the core project and features.

Microservices are separated components and have bounded context with a well-defined interface for each other. So microservice architecture may have over one lumen application that provides support and enhances the functionality of possible Laravel powered web applications.

What is it for?

Lumen is for those projects and components that want to benefit from the power of Laravel but cannot afford to compromise on some configurability in exchange for high speed.

How to Install Lumen

  • Lumen uses Laravel composer to manage its dependencies with the system.
  • By executing the above statement; It will download and install lumen installer using Composer. Once its installed into your local system then it will allow you to create new directory.
  • On the execution of above statement; it will create new directory with name college. The new directory will have all the dependencies of Lumen already installed.

Alternate way for Installation of Lumenory

  • With above statement; you can install Lumen by issuing Composer create-project command.

Building REST API with Lumen

  • Step 1: Configuration

Replace .env file and default CACHE_DRIVER and QUEUE_DRIVERvalues with below values.

Also Read : [Why should you have a Mobile app for your automotive business?]

  • Step 2: Database and Migration

Now we will create migration file by executing following command.

It will create new migration file in the database.Students table will have following
attributes – first_name, last_name, dob, email.
Below code you need to enter into newly created migration file.

After this – you need to Edit .env file with your database configuration and execute below command.

  • Step 3: Create Student model

Now create app directory and create new model with name student.php and paste following code.

Lumen doesn’t load Eloquent and Facades. To get that; you need to find the below
code and remove comment from there (if commented).

  • Step 4: Setup Controller

Now reach to app/Http/Controller directory and add following code there into controller file.

  • Step 5: Setup Routes

Now the time has come to add routes into your web application. Open web.php and add following code

Now you need to add dummy information to test the web application.

That’s it, Lumen is now successfully installed.

Bottom line

Lumen is laravel, with stripped down speed. It does not bother with sessions, views or other conveniences faced by user as it is optimized for speedy microservices. Try it out by getting in touch with developers at Bytes Technolab. To know how we can bring tools together to build a modern business solution using Laravel, feel free to contact us.

Share with :

Total Ratings 0/5 (0)

Rate Us!

Thanks For Rating Us