If you want to install Laravel in your Local machine, at first you need to set up environment for install laravel.
In your machine should have Xampp or Wamp for http server. Here is the link to install download and install Xampp
In your machine should have installed composer. Here is the documentation of Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
After installing composer, you need to create folder for Laravel Project.
Then give this command in the Terminal Command line for installing Laravel via Composer
composer create-project laravel/laravel example-app
Now open .env file for adding Database name and Database username and password.
For checking php artisan command hints you can check by giving command
php artisan
For example: php artisan make:controller ControllerName
In the web.php file route will be
Route::get('/', 'App\Http\Controllers\[email protected]');
for Laravel version 8.x and from the controller you need to set a function for selecting page like
class HomepageController extends Controller
{
public function index()
{
return view('intro');
}
}
For returning intro.blade.php
Note: If you need to build a static page, then you can just view the page through by default Route but if you need to bring data from Database then you need to create controller. If we want to write route name in the url, we need to declare the route name in the web.php
Route::get('/about-me', 'App\Http\Controllers\[email protected]')->name("about-forkan");
For that case url will be
< href="{{ route('about-forkan') }}">About ME</>