Category: Laravel

  • Session

    Sessions are used to store information about the user across the requests. Laravel provides various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used because it is lightweight. Session can be configured in the file stored at config/session.php. Accessing Session Data To access the session data, we need an…

  • Localization

    Localization feature of Laravel supports different language to be used in application. You need to store all the strings of different language in a file and these files are stored at resources/views directory. You should create a separate directory for each supported language. All the language files should return an array of keyed strings as shown below.…

  • Forms

    Laravel provides various in built tags to handle HTML forms easily and securely. All the major elements of HTML are generated using Laravel. To support this, we need to add HTML package to Laravel using composer. Example 1 Step 1 − Execute the following command to proceed with the same. Step 2 − This will add HTML…

  • Errors and Logging

    This chapter deals with errors and logging in Laravel projects and how to work on them. Errors A project while underway, is borne to have a few errors. Errors and exception handling is already configured for you when you start a new Laravel project. Normally, in a local environment we need to see errors for…

  • Working With Database

    Laravel has made processing with database very easy. Laravel currently supports following 4 databases − The query to the database can be fired using raw SQL, the fluent query builder, and the Eloquent ORM. To understand the all CRUD (Create, Read, Update, Delete) operations with Laravel, we will use simple student management system. Connecting to…

  • Redirections

    Named route is used to give specific name to a route. The name can be assigned using the “as” array key. Note − Here, we have given the name profile to a route user/profile. Redirecting to Named Routes Example Observe the following example to understand more about Redirecting to named routes − Step 1 − Create a view called test.php and save…

  • Blade Templates

    Laravel 5.1 introduces the concept of using Blade, a templating engine to design a unique layout. The layout thus designed can be used by other views, and includes a consistent design and structure. When compared to other templating engines, Blade is unique in the following ways − The complete directory structure of Laravel is shown in…

  • Views

    In MVC framework, the letter “V” stands for Views. It separates the application logic and the presentation logic. Views are stored in resources/views directory. Generally, the view contains the HTML which will be served by the application. Example Observe the following example to understand more about Views − Step 1 − Copy the following code and save it at resources/views/test.php Step 2 −…

  • Response

    A web application responds to a user’s request in many ways depending on many parameters. This chapter explains you in detail about responses in Laravel web applications. Basic Response Laravel provides several different ways to return response. Response can be sent either from route or from controller. The basic response that can be sent is…

  • Cookie

    Cookies play an important role while dealing a user’s session on a web application. In this chapter, you will learn about working with cookies in Laravel based web applications. Creating a Cookie Cookie can be created by global cookie helper of Laravel. It is an instance of Symfony\Component\HttpFoundation\Cookie. The cookie can be attached to the response…