AlmaLinux 9
Sponsored Link

Laravel : Install2023/03/03

Install Laravel which is a PHP Web application framework.
[1] Install PHP Composer first.
# install from EPEL

[root@dlp ~]#
dnf --enablerepo=epel -y install composer

[2] Create a Laravel test project with a common user.
[alma@dlp ~]$
mkdir test-project

[alma@dlp ~]$
cd test-project
# create [my-app] Laravel project

[alma@dlp test-project]$
composer create-project laravel/laravel my-app

Creating a "laravel/laravel" project at "./my-app"
Installing laravel/laravel (v9.1.10)
  - Installing laravel/laravel (v9.1.10): Extracting archive
Created project in /home/alma/test-project/my-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 108 installs, 0 updates, 0 removals


Package manifest generated successfully.
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
> @php artisan key:generate --ansi
Application key set successfully.

[alma@dlp test-project]$
cd my-app

[alma@dlp my-app]$
php artisan serve --host --port=8000

Starting Laravel development server:
[Tue Jun 28 13:28:43 2022] PHP 8.0.13 Development Server ( started
  Access to the URL you set from any client computer, and then that's OK if following site is shown.
[3] Create a sample Hello World app.
[alma@dlp ~]$
cd ~/test-project/my-app
# create [HelloWorldController] controller

[alma@dlp my-app]$
php artisan make:controller HelloWorldController

Controller created successfully.
[alma@dlp my-app]$
vi routes/web.php
# add to the end

Route::get('helloworld', 'App\Http\Controllers\HelloWorldController@index');
[alma@dlp my-app]$
vi app/Http/Controllers/HelloWorldController.php
# add function


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HelloWorldController extends Controller
    public function index()
        return view('helloworld');

[alma@dlp my-app]$
vi resources/views/helloworld.blade.php
# create index

<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hello World</title>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Hello Laravel World!

[alma@dlp my-app]$
php artisan serve --host --port=8000
Matched Content