TABLE OF CONTENT
1. Overview2. URL Generation3. Session4. Validation5. Error Handling6. Conclusion7. CloudThat 8. FAQs1. Overview
Laravel is an open source PHP web framework that uses expressive and elegant syntax. Laravel’s built-in features include a variety compatible packages and extensions. This makes it one of the best options for building modern, full-stack web apps. In my previous blog, I gave you an overview of Understanding the Basic Components of Laravel Framework – Part 2.
This will be the final segment. We will cover topics like URL generation, accessing current URL, error handling techniques and many other topics.
2. URL generation
Laravel offers helpers that can be used to generate URLs for applications. These helpers are used to create URLs for applications. The application will handle the generated URL by using the ‘HTTPS’ or ‘HTTPS’ host.
Accessing The Current URL -If no path is provided to the URL helper, an Illuminate\Routing\UrlGenerator instance is returned, allowing to access information about the current URL
Singed URLs – Laravel allows us to easily create “signed URLs” for named routes. These URLs are signed with a hash that is added to the query. This allows Laravel to verify that it has not been modified since its creation. Signed URLs can be useful for routes that are publically accessible but require layered protection against URL manipulation.
URLs for Controller Actions – The action function generates URLs for the given controller actions. If the controller method accepts route parameter, you can pass an associative array with route parameters as the second argument.
Default Values -In certain cases, we can provide request-wide default values that correspond to specific URL parameters.
Sessions allow you to store information about your user across multiple requests, since HTTP-driven applications do not have state. The user information is stored in a persistent store/backend which can be accessed by subsequent requests. Laravel offers a variety of session backends, which can be accessed via an expressive, unified API.
The application’s session configuration file can be found at
config/session.php1config/session.phpBy default, Laravel is configured to use the ‘file’ session driver, which works well for many applications. If the application is load-balanced over multiple web servers, then we should choose a central store that all servers can access.
The session driver configuration option determines where session data will be stored for each request. Laravel comes with several great drivers:
File – sessions are stored instorage/framework/sessions1storage/framework/sessions
Cookies are encrypted and stored securely in secure cookies
Database – sessions are stored within a relational database
These cache-based stores are fast and store Redis / Memcached sessions
Dynamodb – Sessions are stored in AWS DynamoDB
Array – Sessions are stored in a PHP array, and will not be persistent
Laravel offers several ways to validate incoming data. It offers a variety of validation rules that can be applied to data. Even the ability to validate unique values in a particular database table.
Defining the Routes -The application’s routes are defined in theroutes/web.php1routes/web.phpfile. The GET route will display a form to create a new post. The ‘POST route will store the blog in the database.
Writing the Validation Login. This is the login that will validate the new blog post. We can use the IlluminateHttpR ‘validate’ method.