DONE: first init

This commit is contained in:
2026-10-26 10:03:02 +08:00
parent a2ee286c1a
commit 8a7907a87c
32 changed files with 553 additions and 51 deletions
@@ -0,0 +1,56 @@
<?php
namespace Modules\Auth\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AuthController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
return view('auth::index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('auth::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request) {}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('auth::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('auth::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id) {}
/**
* Remove the specified resource from storage.
*/
public function destroy($id) {}
}
View File
@@ -0,0 +1,46 @@
<?php
namespace Modules\Auth\Providers;
use Nwidart\Modules\Support\ModuleServiceProvider;
use Illuminate\Console\Scheduling\Schedule;
class AuthServiceProvider extends ModuleServiceProvider
{
/**
* The name of the module.
*/
protected string $name = 'Auth';
/**
* The lowercase version of the module name.
*/
protected string $nameLower = 'auth';
/**
* Command classes to register.
*
* @var string[]
*/
// protected array $commands = [];
/**
* Provider classes to register.
*
* @var string[]
*/
protected array $providers = [
EventServiceProvider::class,
RouteServiceProvider::class,
];
/**
* Define module schedules.
*
* @param $schedule
*/
// protected function configureSchedules(Schedule $schedule): void
// {
// $schedule->command('inspire')->hourly();
// }
}
@@ -0,0 +1,27 @@
<?php
namespace Modules\Auth\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array<string, array<int, string>>
*/
protected $listen = [];
/**
* Indicates if events should be discovered.
*
* @var bool
*/
protected static $shouldDiscoverEvents = true;
/**
* Configure the proper event listeners for email verification.
*/
protected function configureEmailVerification(): void {}
}
@@ -0,0 +1,50 @@
<?php
namespace Modules\Auth\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
protected string $name = 'Auth';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')->group(module_path($this->name, '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php'));
}
}
+30
View File
@@ -0,0 +1,30 @@
{
"name": "nwidart/auth",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Auth\\": "app/",
"Modules\\Auth\\Database\\Factories\\": "database/factories/",
"Modules\\Auth\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Auth\\Tests\\": "tests/"
}
}
}
View File
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Auth',
];
@@ -0,0 +1,16 @@
<?php
namespace Modules\Auth\Database\Seeders;
use Illuminate\Database\Seeder;
class AuthDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// $this->call([]);
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"name": "Auth",
"alias": "auth",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Auth\\Providers\\AuthServiceProvider"
],
"files": []
}
+15
View File
@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Auth Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-auth', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
{{ $slot }}
{{-- Vite JS --}}
{{-- {{ module_vite('build-auth', 'resources/assets/js/app.js') }} --}}
</body>
</html>
@@ -0,0 +1,5 @@
<x-auth::layouts.master>
<h1>Hello World</h1>
<p>Module: {!! config('auth.name') !!}</p>
</x-auth::layouts.master>
View File
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Auth\Http\Controllers\AuthController;
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
Route::apiResource('auths', AuthController::class)->names('auth');
});
+8
View File
@@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Auth\Http\Controllers\AuthController;
Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('auths', AuthController::class)->names('auth');
});
View File
View File
+41
View File
@@ -0,0 +1,41 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
// Uncomment the import for your frontend framework:
// import vue from '@vitejs/plugin-vue';
// import react from '@vitejs/plugin-react';
// import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
build: {
outDir: '../../public/build-auth',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-auth',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
// Uncomment the plugin for your frontend framework:
// vue({
// template: {
// transformAssetUrls: {
// base: null,
// includeAbsolute: false,
// },
// },
// }),
// react(),
// svelte(),
],
resolve: {
alias: {
'@': __dirname + '/resources/js',
},
},
});
+45 -45
View File
@@ -1,61 +1,36 @@
services:
laravel.test:
build:
context: './vendor/laravel/sail/runtimes/8.5'
context: ./vendor/laravel/sail/runtimes/8.5
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: 'sail-8.5/app'
WWWGROUP: "${WWWGROUP}"
image: sail-8.5/app
extra_hosts:
- 'host.docker.internal:host-gateway'
- "host.docker.internal:host-gateway"
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
- "${APP_PORT:-80}:80"
- "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
environment:
WWWUSER: '${WWWUSER}'
WWWUSER: "${WWWUSER}"
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
IGNITION_LOCAL_SITES_PATH: '${PWD}'
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
IGNITION_LOCAL_SITES_PATH: "${PWD}"
volumes:
- '.:/var/www/html'
- ".:/var/www/html"
networks:
- sail
depends_on:
- mysql
- redis
- mailpit
mysql:
image: 'mysql:8.4'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_EXTRA_OPTIONS: '${MYSQL_EXTRA_OPTIONS:-}'
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s
- pgsql
redis:
image: 'redis:alpine'
image: "redis:alpine"
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
- "${FORWARD_REDIS_PORT:-6379}:6379"
volumes:
- 'sail-redis:/data'
- "sail-redis:/data"
networks:
- sail
healthcheck:
@@ -66,17 +41,42 @@ services:
retries: 3
timeout: 5s
mailpit:
image: 'axllent/mailpit:latest'
image: "axllent/mailpit:latest"
ports:
- '${FORWARD_MAILPIT_PORT:-1025}:1025'
- '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
- "${FORWARD_MAILPIT_PORT:-1025}:1025"
- "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
networks:
- sail
pgsql:
image: "postgres:18-alpine"
ports:
- "${FORWARD_DB_PORT:-5432}:5432"
environment:
PGPASSWORD: "${DB_PASSWORD:-secret}"
POSTGRES_DB: "${DB_DATABASE}"
POSTGRES_USER: "${DB_USERNAME}"
POSTGRES_PASSWORD: "${DB_PASSWORD:-secret}"
volumes:
- "sail-pgsql:/var/lib/postgresql"
- "./vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql"
networks:
- sail
healthcheck:
test:
- CMD
- pg_isready
- "-q"
- "-d"
- "${DB_DATABASE}"
- "-U"
- "${DB_USERNAME}"
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
sail-redis:
driver: local
sail-pgsql:
driver: local
+9 -2
View File
@@ -12,7 +12,8 @@
"php": "^8.3",
"laravel/framework": "^13.17",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^3.0"
"laravel/tinker": "^3.0",
"nwidart/laravel-modules": "^13.2"
},
"require-dev": {
"fakerphp/faker": "^1.23",
@@ -75,6 +76,11 @@
"extra": {
"laravel": {
"dont-discover": []
},
"merge-plugin": {
"include": [
"Modules/*/composer.json"
]
}
},
"config": {
@@ -83,7 +89,8 @@
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
"php-http/discovery": true,
"wikimedia/composer-merge-plugin": true
}
},
"minimum-stability": "stable",
Generated
+145 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0e308dcd21ed728146a3d0f78862dc52",
"content-hash": "8fe4989870c9af337cdd73028d255255",
"packages": [
{
"name": "brick/math",
@@ -2612,6 +2612,94 @@
],
"time": "2026-02-16T23:10:27+00:00"
},
{
"name": "nwidart/laravel-modules",
"version": "v13.2.0",
"source": {
"type": "git",
"url": "https://github.com/nWidart/laravel-modules.git",
"reference": "59714840708a2aece19e810764473f53227c35fe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nWidart/laravel-modules/zipball/59714840708a2aece19e810764473f53227c35fe",
"reference": "59714840708a2aece19e810764473f53227c35fe",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"ext-simplexml": "*",
"php": "^8.3",
"wikimedia/composer-merge-plugin": "^2.1"
},
"require-dev": {
"larastan/larastan": "^3.9.3",
"laravel/framework": "^13.0",
"laravel/pint": "^1.16",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^11.0",
"phpunit/phpunit": "^12.0",
"spatie/phpunit-snapshot-assertions": "^5.0"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Module": "Nwidart\\Modules\\Facades\\Module"
},
"providers": [
"Nwidart\\Modules\\LaravelModulesServiceProvider"
]
},
"branch-alias": {
"dev-master": "13.x-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Nwidart\\Modules\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com",
"homepage": "https://nicolaswidart.com",
"role": "Developer"
}
],
"description": "Laravel Module management",
"keywords": [
"laravel",
"module",
"modules",
"nwidart",
"rad"
],
"support": {
"issues": "https://github.com/nWidart/laravel-modules/issues",
"source": "https://github.com/nWidart/laravel-modules/tree/v13.2.0"
},
"funding": [
{
"url": "https://github.com/dcblogdev",
"type": "github"
},
{
"url": "https://github.com/nwidart",
"type": "github"
}
],
"time": "2026-10-25T18:32:55+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.10.0",
@@ -6104,6 +6192,62 @@
}
],
"time": "2026-04-26T05:33:54+00:00"
},
{
"name": "wikimedia/composer-merge-plugin",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/wikimedia/composer-merge-plugin.git",
"reference": "a03d426c8e9fb2c9c569d9deeb31a083292788bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wikimedia/composer-merge-plugin/zipball/a03d426c8e9fb2c9c569d9deeb31a083292788bc",
"reference": "a03d426c8e9fb2c9c569d9deeb31a083292788bc",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1||^2.0",
"php": ">=7.2.0"
},
"require-dev": {
"composer/composer": "^1.1||^2.0",
"ext-json": "*",
"mediawiki/mediawiki-phan-config": "0.11.1",
"php-parallel-lint/php-parallel-lint": "~1.3.1",
"phpspec/prophecy": "~1.15.0",
"phpunit/phpunit": "^8.5||^9.0",
"squizlabs/php_codesniffer": "~3.7.1"
},
"type": "composer-plugin",
"extra": {
"class": "Wikimedia\\Composer\\Merge\\V2\\MergePlugin",
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Wikimedia\\Composer\\Merge\\V2\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bryan Davis",
"email": "bd808@wikimedia.org"
}
],
"description": "Composer plugin to merge multiple composer.json files",
"support": {
"issues": "https://github.com/wikimedia/composer-merge-plugin/issues",
"source": "https://github.com/wikimedia/composer-merge-plugin/tree/v2.1.0"
},
"time": "2023-04-15T19:07:00+00:00"
}
],
"packages-dev": [
@@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
@@ -29,7 +29,7 @@ return new class extends Migration
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->uuid('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
+3
View File
@@ -0,0 +1,3 @@
{
"Auth": true
}