#laravel query string route
Explore tagged Tumblr posts
Text
Prevent HTTP Parameter Pollution in Laravel with Secure Coding
Understanding HTTP Parameter Pollution in Laravel
HTTP Parameter Pollution (HPP) is a web security vulnerability that occurs when an attacker manipulates multiple HTTP parameters with the same name to bypass security controls, exploit application logic, or perform malicious actions. Laravel, like many PHP frameworks, processes input parameters in a way that can be exploited if not handled correctly.

In this blog, we’ll explore how HPP works, how it affects Laravel applications, and how to secure your web application with practical examples.
How HTTP Parameter Pollution Works
HPP occurs when an application receives multiple parameters with the same name in an HTTP request. Depending on how the backend processes them, unexpected behavior can occur.
Example of HTTP Request with HPP:
GET /search?category=electronics&category=books HTTP/1.1 Host: example.com
Different frameworks handle duplicate parameters differently:
PHP (Laravel): Takes the last occurrence (category=books) unless explicitly handled as an array.
Express.js (Node.js): Stores multiple values as an array.
ASP.NET: Might take the first occurrence (category=electronics).
If the application isn’t designed to handle duplicate parameters, attackers can manipulate input data, bypass security checks, or exploit business logic flaws.
Impact of HTTP Parameter Pollution on Laravel Apps
HPP vulnerabilities can lead to:
✅ Security Bypasses: Attackers can override security parameters, such as authentication tokens or access controls. ✅ Business Logic Manipulation: Altering shopping cart data, search filters, or API inputs. ✅ WAF Evasion: Some Web Application Firewalls (WAFs) may fail to detect malicious input when parameters are duplicated.
How Laravel Handles HTTP Parameters
Laravel processes query string parameters using the request() helper or Input facade. Consider this example:
use Illuminate\Http\Request; Route::get('/search', function (Request $request) { return $request->input('category'); });
If accessed via:
GET /search?category=electronics&category=books
Laravel would return only the last parameter, category=books, unless explicitly handled as an array.
Exploiting HPP in Laravel (Vulnerable Example)
Imagine a Laravel-based authentication system that verifies user roles via query parameters:
Route::get('/dashboard', function (Request $request) { if ($request->input('role') === 'admin') { return "Welcome, Admin!"; } else { return "Access Denied!"; } });
An attacker could manipulate the request like this:
GET /dashboard?role=user&role=admin
If Laravel processes only the last parameter, the attacker gains admin access.
Mitigating HTTP Parameter Pollution in Laravel
1. Validate Incoming Requests Properly
Laravel provides request validation that can enforce strict input handling:
use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; Route::get('/dashboard', function (Request $request) { $validator = Validator::make($request->all(), [ 'role' => 'required|string|in:user,admin' ]); if ($validator->fails()) { return "Invalid Role!"; } return $request->input('role') === 'admin' ? "Welcome, Admin!" : "Access Denied!"; });
2. Use Laravel’s Input Array Handling
Explicitly retrieve parameters as an array using:
$categories = request()->input('category', []);
Then process them safely:
Route::get('/search', function (Request $request) { $categories = $request->input('category', []); if (is_array($categories)) { return "Selected categories: " . implode(', ', $categories); } return "Invalid input!"; });
3. Encode Query Parameters Properly
Use Laravel’s built-in security functions such as:
e($request->input('category'));
or
htmlspecialchars($request->input('category'), ENT_QUOTES, 'UTF-8');
4. Use Middleware to Filter Requests
Create middleware to sanitize HTTP parameters:
namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; class SanitizeInputMiddleware { public function handle(Request $request, Closure $next) { $input = $request->all(); foreach ($input as $key => $value) { if (is_array($value)) { $input[$key] = array_unique($value); } } $request->replace($input); return $next($request); } }
Then, register it in Kernel.php:
protected $middleware = [ \App\Http\Middleware\SanitizeInputMiddleware::class, ];
Testing Your Laravel Application for HPP Vulnerabilities
To ensure your Laravel app is protected, scan your website using our free Website Security Scanner.

Screenshot of the free tools webpage where you can access security assessment tools.
You can also check the website vulnerability assessment report generated by our tool to check Website Vulnerability:

An Example of a vulnerability assessment report generated with our free tool, providing insights into possible vulnerabilities.
Conclusion
HTTP Parameter Pollution can be a critical vulnerability if left unchecked in Laravel applications. By implementing proper validation, input handling, middleware sanitation, and secure encoding, you can safeguard your web applications from potential exploits.
🔍 Protect your website now! Use our free tool for a quick website security test and ensure your site is safe from security threats.
For more cybersecurity updates, stay tuned to Pentest Testing Corp. Blog! 🚀
3 notes
·
View notes
Text
Recent Updates in Laravel 11: Enhancing the Developer Experience
Laravel, one of the most popular PHP frameworks, has consistently delivered powerful tools and features for developers. With the release of Laravel 11, the framework has introduced several enhancements and updates to make development faster, more reliable, and easier. Here, we take a closer look at the latest updates as of January 15, 2025, focusing on the improvements brought by the recent patch versions.
Patch Update: v11.38.2 (January 15, 2025)
The Laravel team continues to refine the framework by:
Simplifying the Codebase: The introduction of the qualifyColumn helper method helps streamline database interactions, making queries more intuitive and efficient.
Postgres Connection Fixes: Reverting support for missing Postgres connection options ensures compatibility with diverse database setups.
Database Aggregation Stability: A rollback of recent changes to database aggregate by group methods resolves issues with complex queries.
Patch Update: v11.38.1 (January 14, 2025)
This patch focused on ensuring stability by:
Reverting Breaking Changes: Addressing the unexpected impact of replacing string class names with ::class constants. This ensures existing projects continue to work without modifications.
Improving Test Coverage: Added a failing test case to highlight potential pitfalls, leading to better framework reliability.
Patch Update: v11.38.0 (January 14, 2025)
Version 11.38.0 brought significant new features, including:
Enhanced Eloquent Relations: New relation existence methods make working with advanced database queries easier.
Fluent Data Handling: Developers can now set data directly on a Fluent instance, streamlining how data structures are manipulated.
Advanced URI Parsing: URI parsing and mutation updates enable more flexible and dynamic routing capabilities.
Dynamic Builders: Fluent dynamic builders have been introduced for cache, database, and mail. This allows developers to write expressive and concise code.
Request Data Access: Simplified access to request data improves the overall developer experience when handling HTTP requests.

Why Laravel 11 Stands Out
Laravel 11 continues to prioritize developer convenience and project scalability. From simplified migrations to improved routing and performance optimizations, the framework is designed to handle modern web development challenges with ease. The following key features highlight its importance:
Laravel Reverb: A first-party WebSocket server for real-time communication, seamlessly integrating with Laravel's broadcasting capabilities.
Streamlined Directory Structure: Reducing default files makes project organization cleaner.
APP_KEY Rotation: Graceful handling of APP_KEY rotations ensures secure and uninterrupted application operation.
Which is the Best Software Development Company in Indore?As you explore the latest updates in Laravel 11 and enhance your development projects, you may also be wondering which is the best software development company in Indore to partner with for your next project. The city is home to a number of top-tier companies offering expert services in Laravel and other modern web development frameworks, making it an ideal location for both startups and enterprise-level businesses. Whether you need a Laravel-focused team or a full-stack development solution, Indore has options that can align with your technical and business requirements.
What’s Next for Laravel?
As the Laravel team prepares to release Laravel 12 in early 2025, developers can expect even more enhancements in performance, scalability, and advanced query capabilities. For those eager to explore the upcoming features, a development branch of Laravel 12 is already available for testing.
Conclusion
With each update, Laravel demonstrates its commitment to innovation and developer satisfaction. The latest updates in Laravel 11 showcase the framework's focus on stability, new features, and ease of use. Whether you’re building small applications or scaling to enterprise-level projects, Laravel 11 offers tools that make development smoother and more efficient.
For the latest updates and in-depth documentation, visit the official Laravel website.
#best software company in indore#software#web development#software design#ui ux design#development#technologies#network#developer#devops#erp
0 notes
Text
Build Portfolio Website in Laravel 11: Your Comprehensive Guide
Building a portfolio website is an essential step for showcasing your skills, projects, and achievements in today's competitive world. Laravel 11, the latest version of the robust PHP framework, offers unparalleled tools and features to create a stunning and functional portfolio website. In this guide, we’ll walk you through the process of building a portfolio website in Laravel 11, ensuring you have a step-by-step roadmap to success.
Why Choose Laravel 11 for Your Portfolio Website?
1. Modern Features
Laravel 11 introduces enhanced routing, improved performance, and advanced tooling that make it the go-to choice for web development.
2. Scalability
Whether you're a freelancer or a business owner, Laravel 11's scalability ensures your website can grow as your portfolio expands.
3. Security
With built-in authentication and security features, Laravel 11 protects your data and provides peace of mind.
4. Community Support
Laravel’s vast community ensures you’ll find solutions to problems, tutorials, and plugins to enhance your website.
Key Features of a Portfolio Website
To build a portfolio website in Laravel 11, ensure it includes:
Homepage: A welcoming introduction.
About Section: Your background and expertise.
Projects: A gallery showcasing your work.
Contact Form: Easy communication.
Blog Section: Share insights and updates.
Responsive Design: Optimized for all devices.
Getting Started with Laravel 11
Step 1: Install Laravel 11
Start by setting up Laravel 11 on your local environment.
composer create-project --prefer-dist laravel/laravel portfolio-website
Step 2: Configure Your Environment
Update your .env file to set up the database and other environment variables.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=portfolio
DB_USERNAME=root
DB_PASSWORD=yourpassword
Step 3: Set Up Authentication
Laravel 11 offers seamless authentication features.
php artisan make:auth
This command generates routes, controllers, and views for user authentication.
Step 4: Design Your Database
Create tables for your portfolio items, such as projects, blogs, and user profiles. Use migrations to structure your database.
php artisan make:migration create_projects_table
In the migration file:
Schema::create('projects', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description');
$table->string('image')->nullable();
$table->timestamps();
});
Run the migration:
php artisan migrate
Building the Frontend
Step 1: Choose a CSS Framework
Laravel integrates well with frameworks like Tailwind CSS and Bootstrap. Install Tailwind CSS for modern and responsive designs:
npm install -D tailwindcss
npx tailwindcss init
Configure your Tailwind file and integrate it into your project.
Step 2: Create Blade Templates
Laravel’s Blade templating engine simplifies building dynamic pages. Create a layout file in resources/views/layouts/app.blade.php:
<!DOCTYPE html>
<html>
<head>
<title>@yield('title')</title>
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>
<div class="container">
@yield('content')
</div>
</body>
</html>
Use this layout in other views:
@extends('layouts.app')
@section('title', 'Home')
@section('content')
<h1>Welcome to My Portfolio</h1>
@endsection
Step 3: Dynamic Content
Fetch portfolio items from the database and display them dynamically using controllers.
public function index() {
$projects = Project::all();
return view('home', compact('projects'));
}
In your Blade template:
@foreach ($projects as $project)
<div class="project">
<h2>{{ $project->title }}</h2>
<p>{{ $project->description }}</p>
<img src="{{ $project->image }}" alt="{{ $project->title }}">
</div>
@endforeach
Advanced Features
1. Search Functionality
Add search to help visitors find specific projects or blogs.
public function search(Request $request) {
$query = $request->input('query');
$projects = Project::where('title', 'LIKE', "%{$query}%")->get();
return view('search-results', compact('projects'));
}
2. File Uploads
Enable uploading images for projects.
public function store(Request $request) {
$request->validate([
'title' => 'required',
'description' => 'required',
'image' => 'nullable|image',
]);
$imagePath = $request->file('image')->store('projects', 'public');
Project::create([
'title' => $request->title,
'description' => $request->description,
'image' => $imagePath,
]);
}
3. Integrate Analytics
Use Google Analytics or similar tools to track visitor behavior.
4. Deploying Your Website
Deploy your Laravel website using platforms like Laravel Forge, AWS, or Heroku. Ensure to optimize the performance with caching and minification.
Optimizing Your Portfolio Website for SEO
Keyword Integration: Use keywords like “Build Portfolio Website in Laravel 11” strategically in titles, meta descriptions, and content.
Fast Loading Times: Optimize images and use caching.
Responsive Design: Ensure compatibility with mobile devices.
Content Strategy: Regularly update your blog to attract organic traffic.
Conclusion
Building a portfolio website in Laravel 11 is an enriching experience that showcases your skills and work to the world. By leveraging the framework’s capabilities and integrating advanced features, you can create a website that stands out in the digital landscape. Start your journey today and make your mark with a professional portfolio website
0 notes
Text
Laravel 10 Redirect Route with Query String Parameters
In Laravel 10, redirecting routes with query string arguments allows you to transmit data between pages while keeping a clean and user-friendly URL structure.
Query string arguments let you to send variables and values between routes, allowing for dynamic content and personalised user experiences.
0 notes
Text
Laravel 6 Advanced - e6 - Pipelines - Laravel
Laravel 6 Advanced – e6 – Pipelines – Laravel
Laravel 6 Advanced – e6 – Pipelines – Laravel
[ad_1]
Pipeline is a design pattern specifically optimized to handle stepped changes to an object. Think of an assembly line, where each step is a pipe and by the end of the line, you have your transformed object. Let’s implement a filtering functionality using the pipeline pattern and Laravel.
For the best experience, follow along in our interactive…
View On WordPress
#container laravel#laravel#laravel 6#laravel 6 tutorial#laravel 6 what&039;s new#laravel advanced#laravel advanced project#laravel container#laravel filter products#laravel filters tutorial#laravel ioc container#laravel ioc service container#laravel pipe dream#laravel pipeline#laravel preview#laravel query builder tutorial#laravel query string route#laravel service container#laravel table filter#service container#service container laravel
0 notes
Text
What are the Key Features of the Laravel?
As a more sophisticated alternative to the CodeIgniter framework, which lacked features like built-in user authentication and authorisation, Laravel was initially developed. When we refer to Laravel's original release, we mean the beta version, which was made available on June 9, 2011, and Laravel 1, which was made available later that month. Laravel 1 was regarded as the best option for websites or applications because it has built-in support for authentication, localization, models, views, sessions, routing, and many more techniques.
Construction of a database table is made possible by Laravel's crucial migration feature. It enables you to modify and distribute the application's database schema. A new column can be added to the table, or an existing one can be eliminated.
Faker is a PHP (Laravel) testing tool that creates fictitious data. Using Faker, you can produce as much test data as you require. The Laravel framework includes Faker. Faker can also be used on your own PHP-based websites or in other frameworks.
A method for automatically adding dummy data to the database is provided by Laravel. The process is referred to as seeding. Developers may quickly add test data to their database table by using the database seeder. By testing with different data formats, it enables developers to identify problems and maximise efficiency, which is quite helpful.
The important distinction in this case is how this release increased Laravel's popularity. Laravel is available in versions 1, 2, 3, 4, 5, 5.1, 5.3, 5.4, 6, 7, and most recently, Laravel 9.
The following are the most important features of Laravel 4.
Database seeding is used to initially populate databases.
There is built-in support for sending a variety of email formats.
There is support for the message queue.
support for the deletion of database records after a predetermined period of time (Soft deletion).
The following are the most important features of Laravel 5.
You can schedule jobs to be executed on a regular basis using the scheduler programme.
An abstraction layer called Flysystem makes it possible to use remote storage in the same way that local file systems are used.
External authentication can be handled more easily with the help of the optional Socialite package.
Package asset management is better with Elixir.
A new internal directory tree structure has been made for produced programmes.
Additionally, version 5.1 was updated.
The following are the most important features of Laravel 8.
Laravel's Jetstream module is used.
In the model factory, classes.
Migratory suffocation
Use Tailwind CSS for usability improvements such as pagination views.
Do you want to learn how to utilise Laravel? Knowledge and tools required
Intermediate understanding of PHP
HTML and CSS fundamentals
An excellent code editor (IDE)
Firefox is an example of a browser.
The following are the most important features of Laravel 9.
PHP Minimum Requirement
Migration of an Anonymous Stub
The Query Builder Interface has been updated.
String Functions in PHP 8
Conclusion
Here we have learned the essential parameters that are required for the Laravel website development using the varieties of Laravel Technologies.
Visit to explore more on What are the Key Features of the Laravel?
Get in touch with us for more!
Contact us on:- +91 987 979 9459 | +1 919 400 9200
Email us at:- [email protected]
#laravel development company USA#laravel development company#laravel development#hire virtual employees#hire dedicated team#Laravel website development
0 notes
Text
How to Use Yajra Datatables in Laravel 9 Application
User data display is a fundamental necessity for web development. This tutorial's main goal is to show you how to use Yajra Datatables, a third-party package, to generate Datatables in Laravel. This Laravel datatables tutorial demonstrates how to construct yajra datatables in Laravel while also teaching us the necessary techniques. We will work to eliminate any ambiguity that may have surrounded your creation of the Laravel datatables example. We'll look at a laravel datatables AJAX example and a laravel Bootstrap datatable simultaneously. Consider a scenario where you are presented with thousands of records and must manually search through each one to find the information you need. Doesn't seem easy, does it? To manage the data dynamically in the table, Datatables provides easy search, pagination, ordering, and sorting functions, in my opinion making our task less dreary. A plug-in driven by jQuery, also known as the Javascript library, is called DataTables. It is a remarkably adaptable tool that adds all of these subtle and cutting-edge features to any static HTML table. It was created on the principles of progressive and dynamic augmentation.
Features
- Pagination - Instant search - Multi-column ordering - Use almost any data source - Easily theme-able - Wide variety of extensions - Mobile friendly Even though we will only be using a few functionalities, such as search, sort, and pagination, we will attempt to integrate these elements with aesthetically pleasing HTML tables that are robust from a UI/UX standpoint.
Table of Contents
- Install Laravel App - Install Yajra Datatables - Set Up Model and Migrations - Insert Dummy Data - Create Controller - Define Route - Create View
Install Laravel App
In general, deploying a new Laravel application is the main emphasis of our initial step. Install the sacred canon by executing the artisan command listed below. composer create-project laravel/laravel laravel-yajra-datatables --prefer-dist cd laravel-yajra-datatables
Install Yajra Datatable Package
Yajra Datatables Library is a jQuery DataTables API for Laravel 4|5|6|7, and I wonder whether you've heard of it. By taking into account the Eloquent ORM, Fluent Query Builder, or Collection, this plugin manages the server-side operations of the DataTables jQuery plugin through the AJAX option. The following command should theoretically assist you in installing the Yajra DataTable plugin in Laravel. composer require yajra/laravel-datatables-oracle Expand the basic functions of the package, such as the datatable service provider in the providers section and the alias inside the config/app.php file. ..... ..... 'providers' => 'aliases' => ..... ..... Continue by running the vendor publish command; this step is optional. php artisan vendor:publish --provider="YajraDataTablesDataTablesServiceProvider"
Set Up Model and Migrations
Run a command to generate a model, which contains the database table's schema. php artisan make:model Student -m Add the following code to the file database/migrations/timestamp create students table.php. public function up() { Schema::create('students', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->string('username'); $table->string('phone'); $table->string('dob'); $table->timestamps(); }); } Open the Student.php file in app/Models and add the schema to the $fillable array. Read the full article
#howtouseyajradatatablesinlaravel9#laravel9datatablesajaxexample#laravel9datatablesexample#laravel9installyajradatatables#laravel9yajradatatablesexample#laravel9yajradatatablesserversiteserverside
0 notes
Text
Laravel VII: Abbreviated | Web Development - Yudiz Solutions Pvt. Ltd.
Overview:
Hello there. As we all know the Laracon Online 2020, the largest online Laravel conference, took place on 26 February 2020. Our developer happened to attend a Laracon Online Viewing Party and according to his experience we are going to share with you the highlights. We’re going to focus on Laravel 7 here. Yes, it’s here and stick till the end to know all about it.

So as most of you might know Taylor Otwell was one of the speakers at the event. He gave us a complete walkthrough for Laravel VII and we are going to cover most of it here.
What is Laravel Airlock?
Airlock is a lightweight Token Generation and verification tool (Provides Authentication) mostly for SPAs (Single Page Applications), where users can generate multiple API tokens and like passport, we can set the roles for particular auth token.
AirLock will work with Laravel 6.x, but everyone recommends using it with Laravel 7.x and you also need to use Laravel UI 2.x for UI files.
We can set allowed domain in config file, so if a request comes from that particular server then and only then that request gets served. So we can say airlock is a similar kind of structure like a passport but it’s for SPA.
For better understanding,we can compare AirLock mechanism with Node/Angular project where frontend API will use AuthToken. Authtoken is similar kind of personal access token which we are used in the passport for mobile authentication
Key features of AirLock:
EncryptCookies
AddQueuedCookiesToResponse
StartSession
VerifyCsrfToken
Laravel Custom Casts:
In Laravel VII, we can create our own casting for an eloquent model, there are two methods, “get()” and “set()”
“get()” method is used to convert raw data into casted data.
“set()” method is used to convert casted data into raw data value.
For example, if we need to decode data when we receive it and encode data when we save details, we can use these methods like this:
Syntax for “get()” method:
public function get($model, $key, $value, $attributes) {
return json_decode($value, true);
}
Syntax for “set()” method:
public function set($model, $key, $value, $attributes) {
return json_encode($value, true);
}
For eloquent we need to define detail as:
protected $casts = [
'column_name' => Json::class,
];
So now every time we fetch data of a column, we get JSON decoded data and when the data is saved to the column it will get encoded.
HTTP Client:
HTTP Client is used for making an HTTP request from one website to another website or web application. For HTTP client you have to install guzzlehttp/guzzle package into your project. We can make any request along with header through the HTTP Client, also we get the details of response and other params directly, like if we want the main body of the response, then just write down $response->body() this will return the body. If we need to check the status of the response then just need to call $response->status().
Likewise, we can use the following details:
$response->body();
$response->json();
$response->status();
$response->ok();
$response->successful();
$response->serverError();
$response->clientError();
$response->header($header);
$response->headers();
And for the routes we have to write details like:
$response = Http::withHeaders([
'accept' => 'application/json',
])->post('http://domain.com/users/list', [
'name' => 'User',
]);
So now onwards we can fire the API from the web routes along with the Headers. We can also pass the Bearer Token by just adding:
$response = Http::withToken('token')->post('http://www.domain.com', ['name' => 'User']);
Fluent String Operations:
We can all agree how useful string operations are as they help us manipulate strings easily and without much hassle. Thanks to Laravel VII, some new and useful string operations were added in this version. String operations such as trim(), replace(‘x’, ‘y’), after(), before(), words() and many more now will be available in Laravel VII.
CORS Support:
Laravel VII also came with the fresh first-party package “CORS” along with options, so now no need to create custom middleware for the same, just configure the config files and use CORS services.
Stub Customization:
This is one of the best updates of Laravel. This will help us to boost up the speed of development. For example, whenever we create a new Model, we will write protected $guarded = [*] in all the models, it becomes a bit time consuming if you see it on a larger picture. So now, we can create our own stub for these kinds of changes, So, if we added protected $guarded = [*] into stub then whenever we create a new model, this line will be added automatically. For example, in all tables we need one default column $table->string(‘custom_id’), in all the migrates, so we will publish the stub and customize it.
Route Model Binding:
This is one of the most interesting features of Laravel 7. In the older version, we can bind any model to route, for example:
Route::get('user/{user}', function(User $user) {
dd($user);
});
// domain.com/user/1
Here we’ll get the user’s personal details like we applied dependency injection of the User model. In Laravel 7, there is support for Implicit Model Binding, such as if I want to get the user’s details based on the user’s name then I’ll get details by adding simple “:” after model’s name.
Route::get('user/{user:username}', function(User $user){
return $user;
});
// domain.com/user/kmjadeja
We can also add custom keys and scoping for the Route Model Binding, it’s a very useful thing which can help us to generate SEO friendly URLs.
Custom Keys and Scope:
Sometimes, we need to bind multiple models to the single route and second binding param is dependent on the first building param like we need to get product details that are available under one specific category.
For example, we get all the lists of all the mobile devices which are available under the android category, So now we can do this with simple Route Model Binding
Route::get('category/{category:type}/device/{device:type}',
function (Category $category, Device $device) {
return $device;
});
// domain.com/category/mobile/device/android
One more simple example:
Route::get('user/{user}/posts/{post:slug}',
function (User $user, Post $post) {
return $post;
});
// domain.com/user/1/posts/upcoming-events
Laravel Query Cast:
· Query cast is used to “cast” a column while executing the query.
· Let’s take an example : In the database we save user’s ID, System IP, create_at and updated_at details when user LoggedIn to the system. Now we want to know the last login date of particular user in that case my code will be:
$users = User::select([
'users.*',
'last_logged_in_at' => UserLog::selectRaw('MAX(created_at)')
->whereColumn('user_id', 'users.id')
])->where('id', 1)->withCasts([
'last_logged_in_at' => 'date'
])->get();
So here we get the user’s last loggedIn details in “data”, not in the timestamp, we cast the user’s create_at column to date.
Improve email template design:
In Laravel 7 they have simply improved the email template, made the email template simpler and finer.
Queue Configuration:
Currently, if any queue or job is throwing an exception, each time the job will get executed and throw the exception. In Laravel 7, we can set maxExceptions for jobs. If we set the value equal to 3, in that case, if the job gets the exception more than 3 times, the queue stops automatically. #noExtraExecution
Speed improvements for route-cache:
Laravel 7 have 2x speed improvement for routes, it is mostly used with 800+ routes (big projects), php artisan route:cache is used to cache the routes.
Conclusion:
So that’s all for this blog but that’s not all for Laravel 7 and our discussion on it. Stick with us for the next blog regarding some of the features along with their demo codes. Till then, get started with the master document. You can read the master document here.
Hope, you have liked & enjoyed this blog. If you like this blog then follow us for more such interesting articles on the latest technologies.
0 notes
Text
Why is Laravel the best choice for Large-Scale Web Application Development?

Laravel is a PHP framework for building web applications that include e-commerce sites, CRM, portals and a lot more. It is an open-source MVC framework that keeps updating constantly and can manage all of the common tasks that web applications generally perform.
Such tasks include authentication, routing, database interaction, e-mail, etc. It comes with an easy-to-build authentication functionality. You can always hire a Laravel website development company in India to get your work done.
Laravel is preferred by developers to complete large-scale web application development projects for the following reasons:
1. Advanced Authentication:
User management is an integral part of every web application project, because authentication involves logging in/ registration, rules, permissions, hashing logarithm, security features, and a lot more that developers need to consider while they are developing an app.
The advanced authentication from Laravel helps developers build apps fast and easy by creating logical rules that give relevant access to users. Laravel features like login controller, database migration, and blade templating engine secure user login and logout.
2. Security-
Laravel provides security against SQL Injection if you are using eloquent or query builder. Laravel also protects your cookies with a unique application key to generate secure encrypted strings and hashes.
It also protects from CRF attacks via form classes token method via generation of token code and multiple filters before granting access to a user for a request. You will always be protected from mass alignment vulnerabilities. This allows you to set the field in your table.
3. Enhanced Performance-
Laravel provides high performance of web applications by integrating the tools required while building the web app, for e.g. Redis, Memcached, etc. to enhance the performance. Laravel also comes with page speed packages for the purpose of optimizing performance. From minifying HTML pages, to removing extra lines, white spaces, unnecessary attributes in HTML, etc. Laravel does it all.
4. Open-Source-
The Laravel users are free from vendors locking because Laravel is open-source. Developers can freely work with external components that the vendor does not provide. It has a strong and huge community of developers and is free for developing more features. It provides flexible support if the vendor is unable to provide the same. Being an open source software, Laravel works with open standards and enables easy integration with external components.
5. Database Migration-
Database migration saves you time and it saves you from headache. This feature is a source of version control of your database schema. Within a file, migration allows you to define how your database should look. Hence, you will always have a copy of how your database must be among all the developers on your team. You can expand your database structure without recreating it every time.
Conclusion:
Laravel is the best for large-scale web app development projects because they can begin with their project within moments, with the variety of tools that help build the website faster, easier, more stable and more secure. Almost all the companies offering the best web application development services India use Laravel.
0 notes
Text
300+ TOP LARAVEL Interview Questions and Answers
Laravel Interview Questions for freshers experienced :-
1. What is Laravel? An open source free "PHP framework" based on MVC Design Pattern. It is created by Taylor Otwell. Laravel provides expressive and elegant syntax that helps in creating a wonderful web application easily and quickly. 2. List some official packages provided by Laravel? Below are some official packages provided by Laravel Cashier: Laravel Cashier provides an expressive, fluent interface to Stripe's and Braintree's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle coupons, swapping subscription, subscription "quantities", cancellation grace periods, and even generate invoice PDFs.Read More Envoy: Laravel Envoy provides a clean, minimal syntax for defining common tasks you run on your remote servers. Using Blade style syntax, you can easily setup tasks for deployment, Artisan commands, and more. Currently, Envoy only supports the Mac and Linux operating systems. Read More Passport: Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Alex Bilbie. Read More Scout: Laravel Scout provides a simple, driver based solution for adding full-text search to your Eloquent models. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records.Read More Socialite: Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub and Bitbucket. It handles almost all of the boilerplate social authentication code you are dreading writing.Read More 3. What is the latest version of Laravel? Laravel 5.8.29 is the latest version of Laravel. Here are steps to install and configure Laravel 5.8.29 4. What is Lumen? Lumen is PHP micro framework that built on Laravel's top components. It is created by Taylor Otwell. It is the perfect option for building Laravel based micro-services and fast REST API's. It's one of the fastest micro-frameworks available. 5. List out some benefits of Laravel over other Php frameworks? Top benifits of laravel framework Setup and customization process is easy and fast as compared to others. Inbuilt Authentication System. Supports multiple file systems Pre-loaded packages like Laravel Socialite, Laravel cashier, Laravel elixir,Passport,Laravel Scout. Eloquent ORM (Object Relation Mapping) with PHP active record implementation. Built in command line tool "Artisan" for creating a code skeleton ,database structure and build their migration. 6. List out some latest features of Laravel Framework Inbuilt CRSF (cross-site request forgery ) Protection. Laravel provided an easy way to protect your website from cross-site request forgery (CSRF) attacks. Cross-site request forgeries are malicious attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated. Inbuilt paginations Laravel provides an easy approach to implement paginations in your application.Laravel's paginator is integrated with the query builder and Eloquent ORM and provides convenient, easy-to-use pagination of database. Reverse Routing In Laravel reverse routing is generating URL's based on route declarations.Reverse routing makes your application so much more flexible. Query builder: Laravel's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application and works on all supported database systems. The Laravel query builder uses PDO parameter binding to protect your application against SQL injection attacks. There is no need to clean strings being passed as bindings. read more Route caching Database Migration IOC (Inverse of Control) Container Or service container. 7. How can you display HTML with Blade in Laravel? To display html in laravel you can use below synatax. {!! $your_var !!} 8. What is composer? Composer is PHP dependency manager used for installing dependencies of PHP applications.It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. It provides us a nice way to reuse any kind of code. Rather than all of us reinventing the wheel over and over, we can instead download popular packages. 9. How to install Laravel via composer? To install Laravel with composer run below command on your terminal. composer create-project Laravel/Laravel your-project-name version 10. What is php artisan. List out some artisan commands? PHP artisan is the command line interface/tool included with Laravel. It provides a number of helpful commands that can help you while you build your application easily. Here are the list of some artisian command. php artisan list php artisan help php artisan tinker php artisan make php artisan –versian php artisan make model model_name php artisan make controller controller_name 11. How to check current installed version of Laravel? Use php artisan –version command to check current installed version of Laravel Framework Usage: php artisan --version 12. List some Aggregates methods provided by query builder in Laravel? Aggregate function is a function where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning or measurements such as a set, a bag or a list. Below is list of some Aggregates methods provided by Laravel query builder. count() Usage:$products = DB::table(‘products’)->count(); max() Usage:$price = DB::table(‘orders’)->max(‘price’); min() Usage:$price = DB::table(‘orders’)->min(‘price’); avg() Usage:$price = DB::table(‘orders’)->avg(‘price’); sum() Usage: $price = DB::table(‘orders’)->sum(‘price’); 13. Explain Events in Laravel? Laravel events: An event is an incident or occurrence detected and handled by the program.Laravel event provides a simple observer implementation, that allow us to subscribe and listen for events in our application.An event is an incident or occurrence detected and handled by the program.Laravel event provides a simple observer implementation, that allows us to subscribe and listen for events in our application. Below are some events examples in Laravel:- A new user has registered A new comment is posted User login/logout New product is added. 14. How to turn off CRSF protection for a route in Laravel? To turn off or diasble CRSF protection for specific routes in Laravel open "app/Http/Middleware/VerifyCsrfToken.php" file and add following code in it //add this in your class private $exceptUrls = ; //modify this function public function handle($request, Closure $next) { //add this condition foreach($this->exceptUrls as $route) { if ($request->is($route)) { return $next($request); } } return parent::handle($request, $next);} 15. What happens when you type "php artisan" in the command line? When you type "PHP artisan" it lists of a few dozen different command options. 16. Which template engine Laravel use? Laravel uses Blade Templating Engine. Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application. Blade view files use the .blade.php file extension and are typically stored in the resources/views directory. 17. How can you change your default database type? By default Laravel is configured to use MySQL.In order to change your default database edit your config/database.php and search for ‘default’ => ‘mysql’ and change it to whatever you want (like ‘default’ => ‘sqlite’). 18. Explain Migrations in Laravel? How can you generate migration . Laravel Migrations are like version control for your database, allowing a team to easily modify and share the application’s database schema. Migrations are typically paired with Laravel’s schema builder to easily build your application’s database schema. Steps to Generate Migrations in Laravel To create a migration, use the make:migration Artisan command When you create a migration file, Laravel stores it in /database/migrations directory. Each migration file name contains a timestamp which allows Laravel to determine the order of the migrations. Open the command prompt or terminal depending on your operating system. 19. What are service providers in laravel? Service providers are the central place of all Laravel application bootstrapping. Your own application, as well as all of Laravel’s core services are bootstrapped via service providers. Service provider basically registers event listeners, middleware, routes to Laravel’s service container. All service providers need to be registered in providers array of app/config.php file. 20. How do you register a Service Provider? To register a service provider follow below steps: Open to config/app.php Find ‘providers’ array of the various ServiceProviders. Add namespace ‘Iluminate\Abc\ABCServiceProvider:: class,’ to the end of the array. 21. What are Implicit Controllers? Implicit Controllers allow you to define a single route to handle every action in the controller. You can define it in route.php file with Route: controller method. Usage : Route::controller('base URI',''); 22. What does "composer dump-autoload" do? Whenever we run "composer dump-autoload" Composer re-reads the composer.json file to build up the list of files to autoload. 23. Explain Laravel service container? One of the most powerful feature of Laravel is its Service Container . It is a powerful tool for resolving class dependencies and performing dependency injection in Laravel. Dependency injection is a fancy phrase that essentially means class dependencies are "injected" into the class via the constructor or, in some cases, "setter" methods. 24. How can you get users IP address in Laravel? You can use request’s class ip() method to get IP address of user in Laravel. Usage:public function getUserIp(Request $request){ // Getting ip address of remote user return $user_ip_address=$request->ip(); } 25. What are Laravel Contracts? Laravel’s Contracts are nothing but set of interfaces that define the core services provided by the Laravel framework. 26. How to enable query log in Laravel? Use the enableQueryLog method: Use the enableQueryLog method: DB::connection()->enableQueryLog(); You can get an array of the executed queries by using the getQueryLog method: $queries = DB::getQueryLog(); 27. What are Laravel Facades? Laravel Facades provides a static like interface to classes that are available in the application’s service container. Laravel self ships with many facades which provide access to almost all features of Laravel’s. Laravel Facades serve as "static proxies" to underlying classes in the service container and provides benefits of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods of classes. All of Laravel’s facades are defined in the IlluminateSupportFacades namespace. You can easily access a Facade like so: use IlluminateSupportFacadesCache; Route::get('/cache', function () { return Cache::get('key'); }); 28. How to use custom table in Laravel Model? We can use custom table in Laravel by overriding protected $table property of Eloquent. Below is sample uses: class User extends Eloquent{ protected $table="my_custom_table"; } 29. How can you define Fillable Attribute in a Laravel Model? You can define fillable attribute by overiding the fillable property of Laravel Eloquent. Here is sample uses Class User extends Eloquent{ protected $fillable =array('id','first_name','last_name','age'); } 30. What is the purpose of the Eloquent cursor() method in Laravel? The cursor method allows you to iterate through your database records using a cursor, which will only execute a single query. When processing large amounts of data, the cursor method may be used to greatly reduce your memory usage. Example Usageforeach (Product::where('name', 'bar')->cursor() as $flight) { //do some stuff } 31. What are Closures in Laravel? Closures are an anonymous function that can be assigned to a variable or passed to another function as an argument.A Closures can access variables outside the scope that it was created. 32. What is Kept in vendor directory of Laravel? Any packages that are pulled from composer is kept in vendor directory of Laravel. 33. What does PHP compact function do? Laravel's compact() function takes each key and tries to find a variable with that same name.If the variable is found, them it builds an associative array. 34. In which directory controllers are located in Laravel? We kept all controllers in App/Http/Controllers directory 35. Define ORM? Object-relational Mapping (ORM) is a programming technique for converting data between incompatible type systems in object-oriented programming languages. 36. How to create a record in Laravel using eloquent? To create a new record in the database using Laravel Eloquent, simply create a new model instance, set attributes on the model, then call the save method: Here is sample Usage.public function saveProduct(Request $request ){ $product = new product; $product->name = $request->name; $product->description = $request->name; $product->save(); } 37. How to get Logged in user info in Laravel? Auth::User() function is used to get Logged in user info in Laravel. Usage:- if(Auth::check()){ $loggedIn_user=Auth::User(); dd($loggedIn_user); } 38. Does Laravel support caching? Yes, Laravel supports popular caching backends like Memcached and Redis. By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the file system .For large projects it is recommended to use Memcached or Redis. 39. What are named routes in Laravel? Named routing is another amazing feature of Laravel framework. Named routes allow referring to routes when generating redirects or Url’s more comfortably. You can specify named routes by chaining the name method onto the route definition: Route::get('user/profile', function () { // })->name('profile'); You can specify route names for controller actions: Route::get('user/profile', 'UserController@showProfile')->name('profile'); Once you have assigned a name to your routes, you may use the route's name when generating URLs or redirects via the global route function: // Generating URLs... $url = route('profile'); // Generating Redirects... return redirect()->route('profile'); 40. What are traits in Laravel? Laravel Traits are simply a group of methods that you want include within another class. A Trait, like an abstract classes cannot be instantiated by itself.Trait are created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies. Laravel Triats Exampletrait Sharable { public function share($item) { return 'share this item'; } } You could then include this Trait within other classes like this: class Post { use Sharable; } class Comment { use Sharable; } Now if you were to create new objects out of these classes you would find that they both have the share() method available: $post = new Post; echo $post->share(''); // 'share this item' $comment = new Comment; echo $comment->share(''); // 'share this item' 41. How to create migration via artisan? Use below commands to create migration data via artisan. php artisan make:migration create_users_table 42. Explain validations in Laravel? In Programming validations are a handy way to ensure that your data is always in a clean and expected format before it gets into your database. Laravel provides several different ways to validate your application incoming data.By default Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate all incoming HTTP requests coming from client.You can also validate data in laravel by creating Form Request. 43. Explain Laravel Eloquent? Laravel’s Eloquent ORM is one the most popular PHP ORM (OBJECT RELATIONSHIP MAPPING). It provides a beautiful, simple ActiveRecord implementation to work with your database. In Eloquent each database table has the corresponding MODEL that is used to interact with table and perform a database related operation on the table. Sample Model Class in Laravel.namespace App; use Illuminate\Database\Eloquent\Model; class Users extends Model { } 44. Can laravel be hacked? Answers to this question is NO.Laravel application’s are 100% secure (depends what you mean by "secure" as well), in terms of things you can do to prevent unwanted data/changes done without the user knowing. Larevl have inbuilt CSRF security, input validations and encrypted session/cookies etc. Also, Laravel uses a high encryption level for securing Passwords. With every update, there’s the possibility of new holes but you can keep up to date with Symfony changes and security issues on their site. 45. Does Laravel support PHP 7? Yes,Laravel supports php 7 46. Define Active Record Implementation. How to use it Laravel? Active Record Implementation is an architectural pattern found in software engineering that stores in-memory object data in relational databases. Active Record facilitates the creation and use of business objects whose data is required to persistent in the database. Laravel implements Active Records by Eloquent ORM. Below is sample usage of Active Records Implementation is Laravel. $product = new Product; $product->title = 'Iphone 6s'; $product->save(); Active Record style ORMs map an object to a database row. In the above example, we would be mapping the Product object to a row in the products table of database. 47. List types of relationships supported by Laravel? Laravel support 7 types of table relationships, they are One To One One To Many One To Many (Inverse) Many To Many Has Many Through Polymorphic Relations Many To Many Polymorphic Relations 48. Explain Laravel Query Builder? Laravel's database query builder provides a suitable, easy interface to creating and organization database queries. It can be used to achieve most database operations in our application and works on all supported database systems. The Laravel query planner uses PDO restriction necessary to keep our application against SQL injection attacks. 49. What is Laravel Elixir? Laravel Elixir provides a clean, fluent API for defining basic Gulp tasks for your Laravel application. Elixir supports common CSS and JavaScript preprocessors like Sass and Webpack. Using method chaining, Elixir allows you to fluently define your asset pipeline. 50. How to enable maintenance mode in Laravel 5? You can enable maintenance mode in Laravel 5, simply by executing below command. //To enable maintenance mode php artisan down //To disable maintenance mode php artisan up 51. List out Databases Laravel supports? Currently Laravel supports four major databases, they are :- MySQL Postgres SQLite SQL Server 52. How to get current environment in Laravel 5? You may access the current application environment via the environment method. $environment = App::environment(); dd($environment); 53. What is the purpose of using dd() function iin Laravel? Laravel's dd() is a helper function, which will dump a variable's contents to the browser and halt further script execution. 54. What is Method Spoofing in Laravel? As HTML forms does not supports PUT, PATCH or DELETE request. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method: To generate the hidden input field _method, you may also use the method_field helper function: In Blade template you can write it as below {{ method_field('PUT') }} 55. How to assign multiple middleware to Laravel route ? You can assign multiple middleware to Laravel route by using middleware method. Example:// Assign multiple multiple middleware to Laravel to specific route Route::get('/', function () { // })->middleware('firstMiddleware', 'secondMiddleware'); // Assign multiple multiple middleware to Laravel to route groups Route::group(], function () { // }); Laravel Questions and Answers Pdf Download Read the full article
0 notes
Text
Laravel - Redirect Route dengan Query String
Laravel – Redirect Route dengan Query String
Di sini saya akan memberikan beberapa contoh redirect route dengan beberapa parameter atau query string berbeda. redirect() helper memberikan method route untuk redirect dengan route bernama. Anda juga dapat menambahakan parameter seperti array atau message.
Redirect ke route bernama:
public function show() { return redirect()->route('home'); }
Redirect ke route bernama degnan parameter:
pub…
View On WordPress
0 notes
Text
Yii Tutorial
http://www.viralleakszone.com/yii-tutorial/
Yii Tutorial
Yii Tutorial
Yii Tutorial for Beginners - Learn Yii in simple and easy steps starting from basic
to advanced concepts with examples including Overview, Installation, Create Page,
Application Structure, Entry Scripts, Controllers, Using Controllers, Using Actions,
Models, Widgets, Modules, Views, Layouts, Assets, Asset Conversion, Extensions,
Creating Extensions, HTTP Requests, Responses, URL Formats, URL Routing, Rules of
URL, HTML Forms, Ad Hoc and AJAX Validations, Sessions, Using Flash Data, Cookies,
Using Cookies, Files Upload, Formatting, Pagination, Sorting, Properties,
Data Providers, Data Widgets, ListView Widgets, GridView Widgets, Events,
Creating Event, Behaviors, Creating a Behavior, Configurations, Dependency
Injection, Database Access, Data Access Objects, Query Builder, Active Record,
Database Migration, Theming, RESTful APIs, RESTful APIs in Action, Fields,
Testing, Caching, Fragment Caching, Aliases, Logging, Error Handling,
Authentication, Authorization, Localization, Gii, Creating a Model, Generating
Controller and Module.
Laravel
Laravel Tutorial
Laravel is a powerful MVC PHP framework, designed for developers who need a simple and elegant toolk
Laravel – Overview
IntroductionLaravel is an open-source PHP framework, which is robust and easy to understand. It foll
Laravel – Installation
For managing dependencies, Laravel uses composer. Make sure you have a Composer installed on yo
Laravel – Application Structure
The application structure in Laravel is basically the structure of folders, sub-folders and files in
Laravel – Configuration
In the previous chapter, we have seen that the basic configuration files of Laravel are included in
Laravel – Routing
In Laravel, all requests are mapped with the help of routes. Basic routing routes the request to the
Laravel – Middleware
Middleware acts as a bridge between a request and a response. It is a type of filtering mechanism. T
Laravel – Namespaces
Namespaces are used in various programming languages to create a separate group of variable, functio
Laravel – Controllers
In the MVC framework, the letter ‘C’ stands for Controller. It acts as a directing traffic between V
Laravel – Request
In this chapter, you will learn in detail about Requests in Laravel.Retrieving the Request URIThe&nb
Laravel – Cookie
Cookies play an important role while dealing a user’s session on a web application. In this chapter,
Laravel – Response
A web application responds to a user’s request in many ways depending on many parameters. This chapt
Laravel – Views
In MVC framework, the letter V stands for Views. It separates the application logic a
Laravel – Blade Templates
Laravel 5.1 introduces the concept of using Blade, a templating engine to design a unique layou
Laravel – Redirections
Named route is used to give specific name to a route. The name can be assigned using the as&nbs
Laravel – Working With Database
Laravel has made processing with database very easy. Laravel currently supports following 4 database
Laravel – Errors and Logging
This chapter deals with errors and logging in Laravel projects and how to work on them.ErrorsA proje
Laravel – Forms
Laravel provides various in built tags to handle HTML forms easily and securely. All the major eleme
Laravel – Localization
Localization feature of Laravel supports different language to be used in application. You need to s
Laravel – Session
Sessions are used to store information about the user across the requests. Laravel provides various
Laravel – Validation
Validation is the most important aspect while designing an application. It validates the incoming da
Laravel – File Uploading
Uploading Files in Laravel is very easy. All we need to do is to create a view file where a user can
Laravel – Sending Email
Laravel uses free feature-rich library SwiftMailer to send emails. Using the library funct
Laravel – Ajax
Ajax (Asynchronous JavaScript and XML) is a set of web development techniques utilizing many we
Laravel – Error Handling
Most web applications have specific mechanisms for error handling. Using these, they track errors an
Laravel – Event Handling
Events provide a simple observer implementation which allows a user to subscribe and listen to vario
Laravel – Facades
Facades provide a static interface to classes that are available in the application’s serv
Laravel – Contracts
Laravel contracts are a set of interfaces with various functionalities and core services provided by
Laravel – CSRF Protection
CSRF refers to Cross Site Forgery attacks on web applications. CSRF attacks are the unauthorized act
Laravel – Authentication
Authentication is the process of identifying the user credentials. In web applications, authenticati
Laravel – Authorization
In the previous chapter, we have studied about authentication process in Laravel. This chapter expla
Laravel – Artisan Console
Laravel framework provides three primary tools for interaction through command-line namely: Art
Laravel – Encryption
Encryption is a process of converting a plain text to a message using some algorithms such that any
Laravel – Hashing
Hashing is the process of transforming a string of characters into a shorter fixed value or a key th
Laravel – Understanding Release Process
Every web application framework has its own version history and it is always being updated and maint
Laravel – Useful Resources
The following resources contain additional information on Laravel. Please use them to get more in-de
Discuss Laravel
Laravel is a powerful MVC PHP framework, designed for developers who need a simple and elegant toolk
Laravel Security
Security is important feature while designing web applications. It assures the users of the websit
0 notes
Text
Why laravel is said to be highly secured framework in web application development?
Web Applications are dynamic web sites combined with server side programming which provide functionalities such as interacting with users, connecting to back-end databases, and generating results to browsers.
Client Side Scripting: Client Side Scripting is that is executed or interpreted by using browsers.
Server Side Scripting: Server Side Scripting is the type of code that is executed or interpreted by the web server.
Laravel is a popular framework in development platform that is well known for performance and the active user community. However, no framework could claim to be fully secured, but there are always a way to improve the security of the laravel apps.
Security is one of the important accepts of managing web application. If there is a new security threat looming, it assures the user that their data is secured. It helps in creating adaptable and customizable web applications with inbuilt tools of laravel. Laravel’s default authentication provides encryption to password generated during the installation of laravel. The encryption key uses encryption and cookie classes to generate secured encrypt type strings. it supports and protect your cookies by using a hash and making sure that no one tampers with them.
Various mechanisms to secure website using laravel are:
· Laravel Authentication System
· Cross Site Request Forgery
· SQL Injection
· Protection against XSS (Cross Site Scripting)
· Protecting Routes
· HTTP Basic Authentication
Laravel Authentication System
Laravel already has user authentication process in place with the associated boilerplate code available in the scaffoldings. Laravel use both providers and guards to facilitate in order to authenticate process. Where guards is to authenticate users for user request they make, and providers facilitates to retrieve back the users from the database.
Cross Site Request Forgery (CSRF)
CSRF token is to make sure that external third parties can not able to generate a fake request and should not breach the security. In which laravel creates and integrates a valid token into every request that comes from a form through an AJAX call. When the request is invoked, it compares the request token with the saved user session. If the token doesn’t match, then the request is classified as invalid and no further action will get execute.
SQL Injection
Laravel provide another ways of talking to databases, such as raw SQL queries. Yet, eloquent remains the most popular option and that will learn how to use the ORM because it helps prevent SQL injection attacks caused by malicious SQL queries.
Laravel eloquent ORM uses PDO binding that protects from the SQL injections. This feature ensures that client cannot modify the content of SQL queries.
Protection against XSS (Cross Site Scripting)
At the time of XSS attack, the attacker enters JavaScript into your website. Whenever new visitor get access the affected page of form, the script will be executed with malicious impact. Laravel offer a native support that will protect the code from XSS attack. This feature kicks in automatically and protects the database during the process.
Protecting Routes
Laravel routes are defined in your route files, and that are located in the routes directory. These files are automatically loaded by the laravel framework. The routes file defines routes that are for your web interface. In Laravel you have a default middleware auth which is shipped with in Laravel. These routes are assigned with the web middleware group, in which it provides features like session state and CSRF protection. The routes are stateless and are assign the api middleware group.
HTTP Basic Authentication
Laravel make authenticate implementation very simple. In which, almost everything is configured for developer out of the box. The authentication configuration file is located at confiq folder which contains several well documented options for the behavior of the authentication service. By default, laravel includes an App model in your app directory. This may be used with the default eloquent with authentication driver.
If your application is not using eloquent, developer can use the database authentication driver where it uses the laravel query builder.
Conclusion
Application security is one of the most important concerns while developing a web application. For that every programmer has to use an effective ways to make it more secure. In which laravel takes care of the web application security within its own framework. It use hashed and salted password in which the password will never save as a plain text in a database. It is also using Bcrypt hashing algorithm in order to generate an encrypted type of password. Additionally, this PHP web development framework uses prepared SQL statements that make protect the injection attacks.
0 notes
Text
New Features Incorporated in Laravel 5.6 Version
The latest version of Laravel framework is Laravel 5.6. Laravel always produces the best code which is clean and readable. Laravel is also known for its features like Authentication caching, Routing, Application logic, dependency logic etc. The most important concern when building the large web applications along with Laravel is its performance.
Pros of Laravel for website development
One can get dynamic templates which are light in weight. Also, this process is further facilitated by content seeding.
The most powerful and architectured widgets i.e. CSS and JSS add an overall appeal to your site.
Rather than using any SQL code for writing database queries, to facilitate your developer’s work you can get PHP syntax.
Laravel also offer high-level security with a strong password.
The delays can occur due to repetitive tasks but with the help of Artisan tool which is the powerful tool offering an automated mechanism for the repetitive tasks.

The list of new features in Laravel 5.6 is listed below.
1. Logging improvements:
This is the most improved and one of the biggest features incorporated in the Laravel 5.6 version. At the start, the logging configuration of the version V5.6 moves to config/logging.php to config/app.php.
One can also configure stacks which can send the log messages to multiple handlers. for example, you can even send all the debug messages to the system log, and then send error logs to the slack.
2. Single Server Task Scheduling
If you have any task scheduler which runs on more than one servers, the task runs on each server. One should indicate that the task must run on one of the servers having onOneServer() method.
3. Dynamic Rate Limiting:
Next is the dynamic rate limiting. Laravel 5.6 version introduces this and gives flexibility so that one can easily limit the per-user basis. Look at the example below:
Route::middleware('auth:api', 'throttle:rate_limit,1')
->group(function () {
Route::get('/user', function () {
//
});
});
Here, rate_limit is the attribute of the model App\User which determines the number of requests possible in the provided time limit.
4. Broadcast Channel Classes
Rather than using the closures, you can also use the channel classes in the routes/channels.php file. In order to generate the new channel class, the new version of Laravel i.e. Laravel 5.6 version provides the following:
php artisan make:channel OrderChannel
You register your channel in the routes/channels.php file like so:
use App\Broadcasting\OrderChannel; Broadcast::channel('order.{order}', OrderChannel::class);
5. API Controller Generation
Next, one can even generate the resources controller for API which does not include the edit and create actions which are no more required. These actions are applicable for resource controllers itself while returning the HTML. You can also use an –api flag.
php artisan make:controller API/PhotoController --api
6. Eloquent Date Casting
One can customize individually the formats of eloquent date and time casting. The format can also be used in model serialization to the JSON data or an array.
protected $casts = [ 'birthday' => 'date:Y-m-d', 'joined_at' => 'datetime:Y-m-d H:00', ];
7. Blade Component Aliases
One can also alias the blade components for the suitable access. For example, to store a component at the resources/views/components/alert.blade.php one can use the component() method to alias it in the shorter name.
Blade::component('components.alert', 'alert');
You can then render it with the defined alias:
@component('alert') <p>This is an alert component</p> @endcomponen
8. Argon2 Password Hashing
The new version of Laravel 5.6 also supports a password hashing algorithm for PHP 7.2 and above versions. One can control and check which hashing driver is being used by default in the next configuration file. new config/hashing.phpconfiguration file.
9. UUID Methods
Two new methods are now available in the Illuminate\Support\Str class for generating Universal Unique Identifiers (UUID):
In order to support or illuminate string class to generate UUID, below code is important.
return (string) Str::uuid();
return (string) Str::orderedUuid();
10. Collision
Collision provides error reporting which is a dev dependency.
11. Learning More About Laravel 5.6
In order to upgrade the Laravel version you need to refer the upgrade guide. The up-gradation time required is between 10 to 30 minutes and the mileage varies depending on your application.
Conclusion
Looking at the updates in the newer version of Laravel 5.6, if you want to upgrade your Laravel installation to next version, you need to follow the reference guide. Also, Laravel strives to update your application in between short and major releases. If you make an upgrade from 5.5 to the next version it takes approximately 30 minutes but your mileage might vary depending on your application.
0 notes
Text
How to Get Current URL in Laravel
In this little post, we will perceive how to get the current URL in Laravel, assuming you need to get the current page URL in Laravel, we can utilize numerous methods such as sort current(), full(), request(), URL(). Here I will give you all guide to get the current page URL in Laravel, in this model I have utilized aid and capacity just as so we should begin illustration of in what manner to get the current URL id in Laravel.
Example 1: full() with the Helper and Query string parameters
$currenturl = url()->full(); dd($currenturl);
Example 2: current() with the Helper
$currenturl = url()->current(); dd($currenturl);
Example 3: using the Request
$currenturl = Request::url(); dd($currenturl);
Example 4: current() with the Façade
$currenturl = URL::current(); dd($currenturl);
Example 5: full() with the Facade & Query string parameters.
$currenturl = URL::full(); dd($currenturl);
Get the Previous URL in Laravel
$pre_url= url()->previous(); dd($pre_url);
Get Current Route in Laravel
$cur_route = Route::current()->getName(); dd($cur_route); I hope you will like the content and it will help you to learn How to Get Current URL in Laravel If you like this content, do share. Read the full article
#findcurrenturlinlaravel#getcurrentpageurlinlaravel#getfullurlinlaravel#howtogetcurrenturlinlaravel#laravelgetcurrenturl
0 notes
Text
Building a Vue SPA with Laravel Part 3
News / February 16, 2018
Building a Vue SPA with Laravel Part 3
We will continue building our Vue SPA with Laravel by showing you how to load asynchronous data before the vue-router enters a route.
We left off in Building a Vue SPA With Laravel Part 2 finishing a UsersIndex Vue component which loads users from an API asynchronously. We skimped on building a real API backed by the database and opted for fake data in the API response from Laravel’s factory() method.
If you haven’t read Part 1 and Part 2 of building a Vue SPA with Laravel, I suggest you start with those posts first and then come back. I’ll be waiting for you!
In this tutorial we are also going to swap out our fake /users endpoint with a real one powered by a database. I prefer to use MySQL, but you can use whatever database driver you want!
Our UsersIndex.vue router component is loading the data from the API during the created() lifecycle hook. Here’s what our fetchData() method looks like at the conclusion of Part 2:
created() { this.fetchData(); }, methods: { fetchData() { this.error = this.users = null; this.loading = true; axios .get('/api/users') .then(response => { this.loading = false; this.users = response.data; }).catch(error => { this.loading = false; this.error = error.response.data.message || error.message; }); } }
I promised that I’d show you how to retrieve data from the API before navigating to a component, but before we do that we need to swap our API out for some real data.
Creating a Real Users Endpoint
We are going to create a UsersController from which we return JSON data using Laravel’s new API resources introduced in Laravel 5.5.
Before we create the controller and API resource, let’s first set up a database and seeder to provide some test data for our SPA.
The User Database Seeder
We can create a new users seeder with the make:seeder command:
php artisan make:seeder UsersTableSeeder
The UsersTableSeeder is pretty simple right now—we just create 50 users with a model factory:
<?php use Illuminate\Database\Seeder; class UsersTableSeeder extends Seeder { public function run() { factory(App\User::class, 50)->create(); } }
Next, let’s add the UsersTableSeeder to our database/seeds/DatabaseSeeder.php file:
<?php use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $this->call([ UsersTableSeeder::class, ]); } }
We can’t apply this seeder without first creating and configuring a database.
Configuring a Database
It’s time to hook our Vue SPA Laravel application up to a real database. You can use SQLite with a GUI like TablePlus or MySQL. If you’re new to Laravel, you can go through the extensive documentation on getting started with a database.
If you have a local MySQL instance running on your machine, you can create a new database rather quickly from the command line with the following (assuming you don’t have a password for local development):
mysql -u root -e"create database vue_spa;" # or you could prompt for the password with the -p flag mysql -u root -e"create database vue_spa;" -p
Once you have the database, in the .env file configure the DB_DATABASE=vue_spa. If you get stuck, follow the documentation which should make it easy to get your database working.
Once you have the database connection configured, you can migrate your database tables and add seed data. Laravel ships with a Users table migration that we are using to seed data:
# Ensure the database seeders get auto-loaded composer dump-autoload php artisan migrate:fresh --seed
You can also use the separate artisan db:seed command if you wish! That’s it; you should have a database with 50 users that we can query and return via the API.
The Users Controller
If you recall from Part 2, the fake /users endpoint found in the routes/api.php file looks like this:
Route::get('/users', function () { return factory('App\User', 10)->make(); });
Let’s create a controller class, which also gives us the added benefit of being able to use php artisan route:cache in production, which is not possible with closures. We’ll create both the controller and a User API resource class from the command line:
php artisan make:controller Api/UsersController php artisan make:resource UserResource
The first command is adding the User controller in an Api folder at app/Http/Controllers/Api, and the second command adds UserResource to the app/Http/Resources folder.
Here’s the new routes/api.php code for our controller and Api namespace:
Route::namespace('Api')->group(function () { Route::get('/users', 'UsersController@index'); });
The controller is pretty straightforward; we are returning an Eloquent API resource with pagination:
<?php namespace App\Http\Controllers\Api; use App\User; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Resources\UserResource; class UsersController extends Controller { public function index() { return UserResource::collection(User::paginate(10)); } }
Here’s an example of what the JSON response will look like once we wire up the UserResource with API format:
{ "data":[ { "name":"Francis Marquardt", "email":"[email protected]" }, { "name":"Dr. Florine Beatty", "email":"[email protected]" }, ... ], "links":{ "first":"http:\/\/vue-router.test\/api\/users?page=1", "last":"http:\/\/vue-router.test\/api\/users?page=5", "prev":null, "next":"http:\/\/vue-router.test\/api\/users?page=2" }, "meta":{ "current_page":1, "from":1, "last_page":5, "path":"http:\/\/vue-router.test\/api\/users", "per_page":10, "to":10, "total":50 } }
It’s fantastic that Laravel provides us with the pagination data and adds the users to a data key automatically!
Here’s the UserResource class:
<?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\Resource; class UserResource extends Resource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return [ 'name' => $this->name, 'email' => $this->email, ]; } }
The UserResource transforms each User model in the collection to an array and provides the UserResource::collection() method to transform a collection of users into a JSON format.
At this point, you should have a working /api/users endpoint that we can use with our SPA, but if you are following along, you will notice that our new response format breaks the component.
Fixing the UsersIndex Component
We can quickly get our UsersIndex.vue Component working again by adjusting the then() call to reference the data key where our user data now lives. It might look at little funky at first, but response.data is the response object, so the user data can be set like the following:
this.users = response.data.data;
Here’s the adjusted fetchData() method that works with our new API:
fetchData() { this.error = this.users = null; this.loading = true; axios .get('/api/users') .then(response => { this.loading = false; this.users = response.data.data; }).catch(error => { this.loading = false; this.error = error.response.data.message || error.message; }); }
Fetching Data Before Navigation
Our component is working with our new API, and it’s an excellent time to demonstrate how you might fetch users before navigation to the component occurs.
With this approach, we fetch the data and then navigate to the new route. We can accomplish this by using the beforeRouteEnter guard on the incoming component. An example from the vue-router documentation looks like this:
beforeRouteEnter (to, from, next) { getPost(to.params.id, (err, post) => { next(vm => vm.setData(err, post)) }) },
Check the documentation for the complete example, but suffice it to say that we will asynchronously get the user data, once complete, and only after completion, we trigger next() and set the data on our component (the vm variable).
Here’s what a getUsers function might look like to asynchronously get users from the API and then trigger a callback into the component:
const getUsers = (page, callback) => { const params = { page }; axios .get('/api/users', { params }) .then(response => { callback(null, response.data); }).catch(error => { callback(error, error.response.data); }); };
Note that the method doesn’t return a Promise, but instead triggers a callback on completion or failure. The callback passes to arguments, an error, and the response from the API call.
Our getUsers() method accepts a page variable which ends up in the request as a query string param. If it’s null (no page passed in the route), then the API will automatically assume page=1.
The last thing I’ll point out is the const params value. It will effectively look like this:
{ params: { page: 1 } }
And here’s how our beforeRouteEnter guard uses the getUsers function to get async data and then set it on the component while calling next():
beforeRouteEnter (to, from, next) { const params = { page: to.query.page }; getUsers(to.query.page, (err, data) => { next(vm => vm.setData(err, data)); }); },
This piece is the callback argument in the getUses() call after the data is returned from the API:
(err, data) => { next(vm => vm.setData(err, data)); }
Which is then called like this in getUsers() on a successful response from the API:
callback(null, response.data);
The beforeRouteUpdate
When the component is in a rendered state already, and the route changes, the beforeRouteUpdate gets called, and Vue reuses the component in the new route. For example, when our users navigate from /users?page=2 to /users?page=3.
The beforeRouteUpdate call is similar to beforeRouteEnter. However, the former has access to this on the component, so the style is slightly different:
// when route changes and this component is already rendered, // the logic will be slightly different. beforeRouteUpdate (to, from, next) { this.users = this.links = this.meta = null getUsers(to.query.page, (err, data) => { this.setData(err, data); next(); }); },
Since the component is in a rendered state, we need to reset a few data properties before getting the next set of users from the API. We have access to the component. Therefore, we can call this.setData() (which I have yet to show you) first, and then call next() without a callback.
Finally, here’s the setData method on the UsersIndex component:
setData(err, { data: users, links, meta }) { if (err) { this.error = err.toString(); } else { this.users = users; this.links = links; this.meta = meta; } },
The setData() method uses object destructuring to get the data, links and meta keys coming from the API response. We use the data: users to assign data to the new variable name users for clarity.
Tying the UsersIndex All Together
I’ve shown you pieces of the UsersIndex component, and we are ready to tie it all together, and sprinkle on some very basic pagination. This tutorial isn’t showing you how to build pagination, so you can find (or create) fancy pagination of your own!
Pagination is an excellent way to show you how to navigate around an SPA with vue-router programmatically.
Here’s the full component with our new hooks and methods to get async data using router hooks:
<template> <div class="users"> <div v-if="error" class="error"> <p></p> </div> <ul v-if="users"> <li v-for="{ id, name, email } in users"> <strong>Name:</strong> , <strong>Email:</strong> </li> </ul> <div class="pagination"> <button :disabled="! prevPage" @click.prevent="goToPrev">Previous</button> <button :disabled="! nextPage" @click.prevent="goToNext">Next</button> </div> </div> </template> <script> import axios from 'axios'; const getUsers = (page, callback) => { const params = { page }; axios .get('/api/users', { params }) .then(response => { callback(null, response.data); }).catch(error => { callback(error, error.response.data); }); }; export default { data() { return { users: null, meta: null, links: { first: null, last: null, next: null, prev: null, }, error: null, }; }, computed: { nextPage() { if (! this.meta || this.meta.current_page === this.meta.last_page) { return; } return this.meta.current_page + 1; }, prevPage() { if (! this.meta || this.meta.current_page === 1) { return; } return this.meta.current_page - 1; }, paginatonCount() { if (! this.meta) { return; } const { current_page, last_page } = this.meta; return `${current_page} of ${last_page}`; }, }, beforeRouteEnter (to, from, next) { getUsers(to.query.page, (err, data) => { next(vm => vm.setData(err, data)); }); }, // when route changes and this component is already rendered, // the logic will be slightly different. beforeRouteUpdate (to, from, next) { this.users = this.links = this.meta = null getUsers(to.query.page, (err, data) => { this.setData(err, data); next(); }); }, methods: { goToNext() { this.$router.push({ query: { page: this.nextPage, }, }); }, goToPrev() { this.$router.push({ name: 'users.index', query: { page: this.prevPage, } }); }, setData(err, { data: users, links, meta }) { if (err) { this.error = err.toString(); } else { this.users = users; this.links = links; this.meta = meta; } }, } } </script>
If it’s easier to digest, here’s the UsersIndex.vue as a GitHub Gist.
There are quite a few new things here, so I’ll point out some of the more important points. The goToNext() and goToPrev() methods demonstrate how you navigate with vue-router using this.$router.push:
this.$router.push({ query: { page: `${this.nextPage}`, }, });
We are pushing a new page to the query string which triggers beforeRouteUpdate. I also want to point out that I’m showing you a <button> element for the previous and next actions, primarily to demonstrate programmatically navigating with vue-router, and you would likely use <router-link /> to automatically navigate between paginated routes.
I have introduced three computed properties (nextPage, prevPage, and paginatonCount) to determine the next and previous page numbers, and a paginatonCount to show a visual count of the current page number and the total page count.
The next and previous buttons use the computed properties to determine if they should be disabled, and the “goTo” methods use these computed properties to push the page query string param to the next or previous page. The buttons are disabled when a next or previous page is null at the boundaries of the first and last pages.
There’s probably a bit of redundancy in the code, but this component illustrates using vue-router for fetching data before entering a route!
Don’t forget to make sure you build the latest version of your JavaScript by running Laravel Mix:
# NPM npm run dev # Watch to update automatically while developing npm run watch # Yarn yarn dev # Watch to update automatically while developing yarn watch
Finally, here’s what our SPA looks like after we update the complete UsersIndex.vue component:
What’s Next
We now have a working API with real data from a database, and a simple paginated component which uses Laravel’s API model resources on the backend for simple pagination links and wrapping the data in a data key.
Next, we will work on creating, editing, and deleting users. A /users resource would be locked down in a real application, but for now, we are just building CRUD functionality to learn how to work with vue-router to navigate and pull in data asynchronously.
We could also work on abstracting the axios client code out of the component, but for now, it’s simple, so we’ll leave it in the component until Part 4. Once we add additional API features, we’ll want to create a dedicated module for our HTTP client.
via Laravel News http://ift.tt/2BxHnhd
0 notes