Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching.
iPrism Technologies is a leading Web Development Company, that primarily focuses on client-driven web development solutions. Our Web Development Services includes customer focused website development solutions whether yours is a small scale business, large scale business or corporate business needing Web Development Services.
.iPrism Technologies is a leading Web Development Company, that primarily focuses on client-driven web development solutions. Our Web Development Services includes customer focused website development solutions whether yours is a small scale business, large scale business or corporate business needing Web Development Services.
Tips for Laravel Development:
Cache in Laravel:
Cache is basically an another layer between our website and database. Database queries can be slow, especially when we have lots of traffic.The cache layer basically act as a middle layer to store data that has not been changed between requests. Retrieving data from cache rather than a database is much quicker . There are all kinds of ways to cache data, and laravel makes it easy to do so with small number of method calls
.Cache Configuration in Laravel
Laravel provides a unified API for various caching systems. There is no need to change our code if we want to change between different caching systems. All the cache configuration located at app/config/cache.php. As we can see by default laravel uses file storage system for cache. The other caching systems options are memcached, apc, redis, array and database
.Databases Configuration:
We have to use database to save data for further processing based on the requests and we have to send the specific data as a response. Databases are simply grids of data, not pretty. Fortunately, these days we are spoiled by lovely ORMs that will allow us to access our database rows as object instances. Laravel framework has it's own ORM called Eloquent
.
Laravel has lots of options to work with different databases like MySQL, SQLite, PostgreSQL and SQL Server. As you can see now you have lot of choices when selecting a database platform. In this tutorial we are going to use MySQL to explain examples. But we can easily shift in between different databases. Laravel abstraction layer automatically provided SQL syntax based on the database we choose. Another advantage of laravel abstraction layer is security. We don't have to worry about escaping the values that we send to the database. Laravel will escape the values for us, in an effort to prevent various forms of injection attacks
.Requests & Inputs in Laravel:
In any web application data and it's manipulation is important. Data doesn't always to be a long term thing. The data provided from an HTML form, or attached to a request is, by default, only available for the duration of the request. Before we can work on data from the request, we will first need to retrieve it.Let's see how we can work on data in Laravel framework.
Retrieval
Let's see how we can retrieve some GET data from our URI. This type of data is appended to the URL in the form of key/value pairs
.// app/routes.php
Route::get('/', function()
{
$data = Input::all();
var_dump($data);
});
Responses in Laravel:
URl's using Closures and Controllers actions when we got a Request using web server. But at the same we are also sending a response to every request. But today we will discuss in detail about the responses in Laravel
.
Let's go to our first web request http://domain.com/blog/ and see what kind of response we are sending via route closure below
.// app/routes.php
Route::get('/', function()
{
return 'Blog Home Page!';
});
Here in the above example we are returning a statement called 'Blog Home Page!' to the browser when we get request using a route closure or controller action always
.Basic Routing in Laravel:
I assume you have a new laravel application folder for testing purpose. Let's take a look at a request being made to the Laravel framework
.http://domain.com/blog/page
In this example we are using the http protocol using by most web browsers to access your laravel application hosted on domain.com. The blog/page portion of the URL which we use to route web requests to appropriate logic
.Redirect to URL:
We can redirect to path using Redirect::to("path") and to route using Redirect::route("route") . What if you want to redirect to external url then we use Redirect::away()
Redirect::away('http://www.domain.com');
No comments:
Post a Comment