FreeBSD 14
Sponsored Link

Laravel : Install2024/01/30


Install Laravel which is a PHP Web application framework.

[1] Install PHP Composer and other modules first.
root@dlp:~ #
pkg install -y php83-composer php83-curl php83-session php83-tokenizer php83-xml php83-xmlwriter php83-dom php83-fileinfo php83-gd

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

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

freebsd@dlp:~/test-project $
composer create-project laravel/laravel my-app

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


83 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

   INFO  No publishable resources for tag [laravel-assets].

No security vulnerability advisories found.
> @php artisan key:generate --ansi

   INFO  Application key set successfully.

freebsd@dlp:~/test-project $
cd my-app

freebsd@dlp:~/test-project/my-app $
php artisan serve --host --port=8000

   INFO  Server running on [].

  Press Ctrl+C to stop the server
  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.
freebsd@dlp:~ $
cd ~/test-project/my-app
# create [HelloWorldController] controller

freebsd@dlp:~/test-project/my-app $
php artisan make:controller HelloWorldController

INFO Controller [app/Http/Controllers/HelloWorldController.php] created successfully.
freebsd@dlp:~/test-project/my-app $
vi routes/web.php
# add to last line

Route::get('helloworld', 'App\Http\Controllers\HelloWorldController@index');
freebsd@dlp:~/test-project/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');

freebsd@dlp:~/test-project/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!

freebsd@dlp:~/test-project/my-app $
php artisan serve --host --port=8000
Matched Content