PHP cheatsheet ( linux)

In progress...  

php


High-level plan:

- Update system

- Install PHP (modern version) + essential extensions

- Install Composer (PHP’s dependency manager)

- Install Laravel (PHP framework)

- Test the environment

Note: This was done on  Ubuntu 24.04 with root/sudo access


Update the system

- sudo apt update

- sudo apt upgrade -y

Install PHP (modern version) + essential extensions

- check if php exists with php -v

Laravel-ready set:

sudo apt install -y php8.3-cli php8.3-fpm php8.3-mbstring php8.3-xml php8.3-curl php8.3-zip php8.3-sqlite3 php8.3-mysql php8.3-bcmath php8.3-gd php8.3-intl

this time php -v returns similar to this : 

PHP 8.3.6 (cli) (built: May 25 2026 13:12:06) (NTS)


Install Composer (PHP’s package manager):

curl -sS https://getcomposer.org/installer | php

sudo mv composer.phar /usr/local/bin/composer


- composer --version returns 
 Composer version 2.10.0 2026-05-28 11:22:08
PHP version 8.3.6 (/usr/bin/php8.3)

Create the Laravel project for MyProject.

composer create-project laravel/laravel my_project

What this does?
- Downloads a fresh Laravel app into a folder called my_project.
- Uses Composer to install all required PHP packages (routing, auth tools, DB layer, etc.) into vendor/.
- Sets up the default folder structure and configurations.
Check with cd hutfx_pov && php artisan --version. For me it was Laravel Framework 13.13.0.

Quick mental map:
- app/: Your domain logic—Models, Policies, etc.
- routes/web.php: Where you define URLs for web pages.
- resources/views/: Blade templates (HTML + Laravel syntax).
- database/migrations/: Database schema as code.
- .env: Environment config (DB, keys, etc.). Never commit this.
- vendor/: Auto-generated by Composer. Don’t edit manually.

Start the dev server (for testing in browser):
- cd my_project
- php artisan serve
Open the URL to see the default Laravel page. Couple of notes: 127.0.0.1 means "this computer only"—no one else on the network can reach it. With 0.0.0.0 instead, that would be visible to your whole network.

I use VScode and those are the extension I installed:

code --install-extension bmewburn.vscode-intelephense-client
code --install-extension felixfbecker.php-debug
code --install-extension amiralizadeh9480.laravel-extra-intellisense
code --install-extension onecentlin.laravel5-snippets || true 
code --install-extension mikestead.dotenv || true 
code --install-extension eamodio.gitlens || true 
code --install-extension esbenp.prettier-vscode || true 
code --install-extension dbaeumer.vscode-eslint || true

Next step is to make a simple mock page:
Step 1: Ensure Tailwind is ready, this compiles the CSS so the layout classes work.
-cd my_project
- npm install - Installs all JavaScript/TypeScript/CSS dependencies listed in package.json. Laravel uses Vite + Tailwind for front-end. This downloads them into node_modules so they can run.

- npm run build - Runs a build script (via Vite) that compiles your assets.Processes Tailwind CSS into a final CSS file. Bundles/minifies JS and CSS.  Outputs ready-to-use files (e.g., public/build/) that Blade can load with @vite.

Add new Route for the new page:

Route::get('/name_of_the_page', function () {
return view('name_of_the_page');
});

Step 2: Add a route
Edit routes/web.php.

Step 3: Create the name_of_the_page view

Create: resources/views/name_of_the_page.blade.php by pasting some valid html code like :

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>name of  the page</title>
@vite('resources/css/app.css')
</head>
<body class="min-h-screen bg-slate-950 text-slate-100 p-6">
<header class="mb-6 flex items-center justify-between">
<h1 class="text-2xl font-semibold tracking-tight">My page</h1>
<div class="text-xs text-slate-400">Local dev view</div>
</header>

<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
<!-- Large box: <My box 1 -->
<section class="col-span-1 sm:col-span-2 bg-slate-900 border border-slate-800 rounded-xl p-4">
<div class="text-sm font-medium text-slate-300 mb-1">5q's Data</div>
<div class="text-xs text-slate-400">
- Ingestion status: <span class="text-emerald-400">OK</span><br>
- Last update: 00:02 ago<br>
- Active sources: 14
</div>
</section>

<!-- Large box: My box 2 -->
<section class="col-span-1 sm:col-span-2 bg-slate-900 border border-slate-800 rounded-xl p-4">
<div class="text-sm font-medium text-slate-300 mb-1">My box 2</div>
<div class="text-xs text-slate-400">
- Rendered charts: 8<br>
- Load time: 180ms<br>
- Errors: 0
</div>
</section>

<!-- Large box: My box 3 -->
<section class="col-span-1 sm:col-span-2 bg-slate-900 border border-slate-800 rounded-xl p-4">
<div class="text-sm font-medium text-slate-300 mb-1">My box 3</div>
<div class="text-xs text-slate-400">
- Online: 37<br>
- Offline: 2<br>
- Uptime: 99.8%
</div>
</section>

<!-- Large box: My box 4 -->
<section class="col-span-1 sm:col-span-2 bg-slate-900 border border-slate-800 rounded-xl p-4">
<div class="text-sm font-medium text-slate-300 mb-1">My box 4</div>
<div class="text-xs text-slate-400">
- Models active: 3<br>
- Last run: 00:11 ago<br>
- Next run: 19:00
</div>
</section>

<!-- Small box: My small box 1 -->
<section class="col-span-1 bg-slate-900 border border-slate-800 rounded-xl p-3">
<div class="text-xs font-medium text-slate-300 mb-1">My small box 1</div>
<div class="text-[10px] text-slate-400">
- Status: Monitoring<br>
- Signals: 24
</div>
</section>

<!-- Small box: My small box 2 -->
<section class="col-span-1 bg-slate-900 border border-slate-800 rounded-xl p-3">
<div class="text-xs font-medium text-slate-300 mb-1">My small box 2</div>
<div class="text-[10px] text-slate-400">
- Online: Yes<br>
- Users online: 12
</div>
</section>
</div>
</body>
</html>