# Prepare the working directory
cd /path/to/www
git clone [email protected]:goodyweb/example-app.git
cd /path/to/www/example-app
# Add the Laravel installer globally all throughout composer
composer global require laravel/installer
# Create new app
laravel new laravel-app
# Get inside the working directory and move all files to the
cd laravel-app
mv -f ./* ../
mv -f ./.* ../
cd ../
rmdir laravel-app
# Configure the laravel installation
nano .env
#
php artisan migrate
composer require laravel/breeze --dev
php artisan breeze:install
php artisan migrate
npm install
npm run dev
composer require livewire/livewire
php artisan livewire:publish --config
resources/views/layouts/app.blade.php
<html>
<head>
...
@livewireStyles
</head>
<body>
...
@livewireScripts
</body>
</html>
# Tailwind
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
"./resources/**/*.vue",
],
theme: {
extend: {},
},
plugins: [],
}
resources/css/app.css
@tailwind base;
@tailwind components;
@tailwind utilities;
npm run dev
php artisan make:migration create_users_table --create=users
php artisan make:migration add_role_to_users_table --table=users
$table->dropColumn('status');
$table->dropColumn(['status', 'status_at']);
$table->renameColumn('from', 'to');
$table->decimal('price', 8, 2)->change();
php artisan make:model User
php artisan make:controller UserController
use Illuminate\Support\Facades\Auth;
Auth::user()
php artisan make:livewire Users
use App\Http\Livewire\{Users};
Route::get('/users', Users::class);
php artisan make:command SendEmails
php artisan migrate:refresh --path=database/migrations/timestamped_migration_file.php
use Illuminate\Support\Str;
$slug = Str::slug('Laravel 5 Framework', '-');
use Illuminate\Support\Facades\DB;
Article::create(['title' => 'Traveling to Asia']);
$table->string('column_name_here')->unique();
$table->foreign('user_id')->references('id')->on('users');
route('checkout')
or
route('checkout',['uuid'=>$uuid])
php artisan make:seeder UserSeeder
$this->call([
UserSeeder::class,
]);
GET or POST parameters that are retrievable.
$_POST['name']
is retrievable as:
request()->name
Also, $_GET['name']
is retrievable similarly as:
request()->name
ChatGPT, Laravel Relationships Overview, URL: https://chat.openai.com/share/b60a5e79-0829-4669-a039-16b5e0670b47
php artisan storage:link
<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\WithFileUploads;
use Livewire\Attributes\Validate;
use Illuminate\Support\Str;
class Test extends Component {
use WithFileUploads;
#[Validate('image|max:1024')] // 1MB Max
public $photo;
public function save() {
// Get the file name of the uploaded file
$full_file_name = $this->photo->getClientOriginalName();
// Retrieve parts of the file name
$parts = pathinfo($full_file_name);
// Get the visible file name
$file_name = $parts['filename'];
// Get the extension file name
$extension = $parts['extension'];
// Generate a unique identifier
$uuid = Str::uuid();
// Generate a unique file name
$unique_file_name = "{$file_name}.{$uuid}.{$extension}";
// Store the photo in /path/to/laravel/storage/app/photos
$this->photo->storeAs('photos', $unique_file_name);
}
public function render() {
return view('livewire.test')->layout('layouts.app');
}
}
<div>
<form wire:submit.prevent="save">
@if ($photo)
<img src="{{ $photo->temporaryUrl() }}">
@endif
<input type="file" wire:model="photo">
@error('photo') <span class="error">{{ $message }}</span> @enderror
<button type="submit">Upload</button>
</form>
</div>
-
Generate an App Password for your Laravel-Gmail integration from myaccount.google.com/apppasswords
-
It will ask for the App name, just type in
Gmail
.The App name could be of any value really. It is just important to note that it is about Gmail because of all the services of Google, you will be using the Gmail service. You can also put the name of the Laravel application you are building. It is all up to you.
-
Click the Create button
-
The Generated app password window will popup
-
Copy the 12-character password. It will look like so:
abcd efgh ijkl mnop
-
Remove the spaces to prepare your usable App Password:
From unusable App Password
abcd efgh ijkl mnop
into usable App Password
abcdefghijklmnop
-
Edit the
.env
configuration filenano /path/to/laravel/.env
-
Edit the following configuration values
MAIL_MAILER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=gmail_username MAIL_PASSWORD=gmail_app_password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="[email protected]" MAIL_FROM_NAME="${APP_NAME}"
- Simply replace all instances of
gmail_username
with your actual username in Gmail - Simply replace
gmail_app_password
with the usable App Password you prepared in step #6 — the App Password without spaces
- Simply replace all instances of
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $header ?? 'Default Title' }}</title>
@vite(['resources/css/custom.css'])
@livewireStyles
</head>
<body>
<header>
<h1>{{ $header ?? 'Default Header' }}</h1>
</header>
<main>
{{ $slot }} <!-- Main content -->
</main>
<footer>
<p>My Custom Footer</p>
</footer>
@livewireScripts
</body>
</html>