How do I redirect to another page when clicking a button in Laravel.

Step by Step:-

My next page name is “next”. which we are going to link the page through the button.

  • Step1:- Where you are creating the button, put the link in it.
  • Step2:- Then go to web.php(inside routes) and put some commands.
  • Step3:- Then go to home controller.php and write after the index function

Tagged : / / / / / / /

How to use Composer in Laravel?

What is Composer?

Composer is a tool dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) than for you. Composer is not a package manager in the same a Yum or Apt are. Yes, it deals with “packages” or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default, it does not install anything globally. Thus, it is a dependency manager. It does however support a “global” project for convenience via the global command.

Why use Composer?

  • You have a project that depend on a number of libraries.
  • Some of thoes libraries epen on other libraries.
  • Enable you to declare the libraries you depend on.
  • Find out which versions of which packeges can and need to be installed, and installs them.

You have a project that depends on several libraries. The libraries that I used in my project to create PDF are also supported by other libraries. It gives you the urgency to declare those libraries that you are on these libraries as it will manage them all for you. It will find out which packages are required for the project we have. Which version of the package is required and will install it for you.

Tagged : / / / /

Complete Referance of Blade in Laravel

What is Blade?

Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.

Blade template files use the .blade.php file extension and are typically stored in the resources/views directory

Blade Template

Displaying Data – You may display data that is passed to your Blade views by wrapping the variable in curly braces.

Blade’s {{ }} echo statements are automatically sent through PHP’s htmlspecialchars function to prevent XSS attacks.

Example:- {{$name}}

Calling Function – You may also echo the results of any PHP function by wrapping the function name in curly braces.

Example:- {{ time( ) }}

Note – You can put any PHP code you wish inside of a Blade echo statement.

Comment

Blade also allows you to define comments in your views. However, unlike HTML comments, Blade comments are not included in the HTML returned by your application.

{{– This comment will not be present in the rendered HTML –}}

Conditional Directives

If Directive

If.. Else.. Directive

If… elseif… else… Directive

Empty Directive

Authentication Directives

Auth Directive

Guest Directive

Tagged : /

What is a Framework in Laravel?

What is a Framework?

A framework is a set of conceptual structures and guidelines, used to build something. A framework may include predefined classes and functions that can be used to process input, manage hardware devices, and interact with system software. The purpose of the framework is to allow developers to focus on building a unique feature for their projects rather than writing code from scratch.

Why use Framework?

  • Colection of tools
  • No need to start scratch
  • Save Time
  • Improve Productivity
  • Clean Code
  • Reusable Code
  • Testing
  • Debugging

What is Web Framework?

A Web Framework or web application helps to build Web Applications. A Web framework provides tools and libraries to simplify common web development operations. This can include web services, APIs, and other resources. Web Framework help with a variety of tasks, from templating and database access to session management and code reuse. More than 80% of web app frameworks follow the Model View Controller architecture.

Some Web Framework

  • Laravel
  • Codeigniter
  • Zend
  • Django
  • Spring
Tagged : /

Complete Referance of Controller in Laravel

Controllers

Controllers can group related request handling logic into a single class. Instead of defining all of your request handling logic as Closures in route files, you may wish to organize this behavior using Controller classes.

Controllers are stored in the app/Http/Controllers directory.
Controller extends the base Controller class included with Laravel.

Defining Controller Class

Run Command:- php artisan make:controller

Example:- php artisan make:controller AboutController

Path:- app/Http/Controllers/AboutController.php

Creating Route for Controller Class

Path of Controller :- app/Http/Controllers/AboutController.php

Path of Route:- routes/web.php

Syntax:- Route::get(‘uri’, [ControllerName::class, ‘method_name’]);

Passing Data from Controller to View

Path of Controller :- app/Http/Controllers/AboutController.php

Path of Route:- routes/web.php

Path of View:- resources/views/aboutme.blade.php

Multiple Methods inside Controller

Path of Controller :- app/Http/ControllersAboutController.php

Path of Route:- routes/web.php

Path of aboutme blade file:- resources/views/aboutme.blade.php

Path of aboutyou blade file:- resources/views/aboutyou.blade.php

Single Action Controller

If you would like to define a controller that only handles a single action, you may place a single __invoke method on the controller.

Run Command:- php artisan make:controller ShowAbout –invokable

Path of Controller :- app/Http/Controllers/ShowAboutController.php

Path of Route:- routes/web.php

Path of aboutme blade file:- resources/views/aboutme.blade.php

Tagged : /

How to Install Laravel and Create Project

How to Install Laravel

  • Download the Laravel installer using Composer :
composer global require laravel/installer
  • Then use laravel new command will create a fresh Laravel installation in the directory you specify
laravel new projectname
  • Install Laravel by issuing the Composer create-project command
composer create-project --prefer-dist laravel/laravel projectname
Tagged : /

What is Laravel?

Laravel is a free, open-source PHP based Web Framework for building High End Web Applications, following the Model View Controller architectural pattern and based on Symfony.
It is created by Taylor Otwell.
Laravel Source Code : https://github.com/laravel/framework

Advantages of Laravel

  • Open Source
  • Collection of tools
  • Save Time
  • Improve Productivity
  • Robust and Easy
  • Security of the Application
  • Authentication
  • Routing
  • Templating
Tagged : /

Complete Referance of MVC Design Pattern

Model View Controller (MVC)

The MVC is an architectural pattern that separates an application into three main logical components Model, View, and Controller.
Each of these component has their own role in a Project.
MVC model was first introduced in 1987 in the Smalltalk programming language.
More than 80% of all web app frameworks rely on the Model View Controller architecture.

Model

The model is responsible for getting data from a database, packaging it in data objects that can be understood by other components, and delivering those objects, most of which will happen in response to input from the controller.

View

It represents how data should be presented to the application user. User can read or write the data from view.
Basically it is responsible for showing end user content, we can say it is user interface.
It may consists of HTML, CSS, JS.

Controller

The user can send request by interacting with view, the controller handles these requests and sends to Model then get appropriate response from the Model, sends response to View.
It may also have required logics.
It works as a mediator between View and Model.

Why use MVC?

  • Organized Code
  • Independent Block
  • Reduces the complexity of web applications
  • Easy to Maintain
  • Easy to modify

Basic Structure

  • Assets
    • CSS
    • Images
    • JS
  • Config
    • Database Config File
  • Controllers
  • Model
  • Views
Tagged : /

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 7.2.5”. You are running 7.1.32.

When you using PHP version 7.1.32 within your Laravel project, then showing this type of error in your project. If you want to update the composer still not solve you problem then After that Follow this trick-

add this line in config object of composer.json file

“platform-check”: false

run php artisan config:cache

then run composer dump-autoload in terminal

Tagged : / / / / / / / / / /