├── README.md ├── backend ├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── _docker │ ├── Dockerfile │ └── resources │ │ └── startup.sh ├── app │ ├── Console │ │ └── Kernel.php │ ├── Exceptions │ │ └── Handler.php │ ├── Http │ │ ├── Controllers │ │ │ └── Controller.php │ │ ├── Kernel.php │ │ └── Middleware │ │ │ ├── Authenticate.php │ │ │ ├── EncryptCookies.php │ │ │ ├── PreventRequestsDuringMaintenance.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustHosts.php │ │ │ ├── TrustProxies.php │ │ │ ├── ValidateSignature.php │ │ │ └── VerifyCsrfToken.php │ ├── Models │ │ └── User.php │ └── Providers │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ └── RouteServiceProvider.php ├── artisan ├── bootstrap │ ├── app.php │ └── cache │ │ └── .gitignore ├── composer.json ├── composer.lock ├── config │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── cors.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── queue.php │ ├── sanctum.php │ ├── services.php │ ├── session.php │ └── view.php ├── database │ ├── .gitignore │ ├── factories │ │ └── UserFactory.php │ ├── migrations │ │ ├── 2014_10_12_000000_create_users_table.php │ │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ └── 2019_12_14_000001_create_personal_access_tokens_table.php │ └── seeders │ │ └── DatabaseSeeder.php ├── package.json ├── phpunit.xml ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── index.php │ └── robots.txt ├── resources │ ├── css │ │ └── app.css │ ├── js │ │ ├── app.js │ │ └── bootstrap.js │ └── views │ │ └── welcome.blade.php ├── routes │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php ├── storage │ ├── app │ │ ├── .gitignore │ │ └── public │ │ │ └── .gitignore │ ├── framework │ │ ├── .gitignore │ │ ├── cache │ │ │ ├── .gitignore │ │ │ └── data │ │ │ │ └── .gitignore │ │ ├── sessions │ │ │ └── .gitignore │ │ ├── testing │ │ │ └── .gitignore │ │ └── views │ │ │ └── .gitignore │ └── logs │ │ └── .gitignore ├── tests │ ├── CreatesApplication.php │ ├── Feature │ │ └── ExampleTest.php │ ├── TestCase.php │ └── Unit │ │ └── ExampleTest.php └── vite.config.js ├── composer-setup.php └── docker-compose.dev.yml /README.md: -------------------------------------------------------------------------------- 1 | **# Laravel Development with Docker Compose** 2 | 3 | ## Streamline your local Laravel development with Docker Compose! 4 | 5 | This project provides a hassle-free setup for running Laravel locally using Docker Compose. It includes: 6 | 7 | - **Laravel 8.x (or compatible)** 8 | - **PHP 8.3** 9 | - **MariaDB** 10 | - **Redis** 11 | - **Optimized permissions for seamless file handling** 12 | 13 | **Key Features:** 14 | 15 | - **Simple setup:** Get your Laravel environment up and running quickly. 16 | - **Development-friendly:** Hot reloading for efficient coding and testing. 17 | - **Permission handling:** Avoid file permission issues between host and containers. 18 | - **Easy maintenance:** Update dependencies and configuration with ease. 19 | 20 | **Getting Started:** 21 | 22 | 1. **Clone this repository:** 23 | ```bash 24 | git clone https://github.com//.git 25 | ``` 26 | 27 | 2. **Set up environment variables:** 28 | - Copy the `.env.example` file to `.env`: 29 | ```bash 30 | cp .env.example .env 31 | ``` 32 | - Fill in the `USER` and `UID` values in the `.env` file. You can find your UID by typing `id` in your terminal. 33 | 34 | 3. **Build the Docker images:** 35 | ```bash 36 | docker compose -f docker-compose.dev.yml build 37 | ``` 38 | 39 | 4. **Start the containers:** 40 | ```bash 41 | docker compose -f docker-compose.dev.yml up 42 | ``` 43 | 44 | 5. **Access your application:** 45 | Visit `http://localhost:8000` in your browser. 46 | 47 | **Additional Notes:** 48 | 49 | - **Database configuration:** Use `mariadb` as the database host in your Laravel configuration. 50 | - **Redis configuration:** Use `redis` as the Redis host in your Laravel configuration. 51 | - **File permissions:** The `docker-compose.dev.yml` file is configured to map the user and group ID of your host machine to the application container, ensuring smooth file operations. 52 | 53 | **Happy developing!** 54 | 55 | -------------------------------------------------------------------------------- /backend/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /backend/.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=laravel 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_APP_NAME="${APP_NAME}" 55 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 56 | VITE_PUSHER_HOST="${PUSHER_HOST}" 57 | VITE_PUSHER_PORT="${PUSHER_PORT}" 58 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 59 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 60 | -------------------------------------------------------------------------------- /backend/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .env.production 11 | .phpunit.result.cache 12 | Homestead.json 13 | Homestead.yaml 14 | auth.json 15 | npm-debug.log 16 | yarn-error.log 17 | /.fleet 18 | /.idea 19 | /.vscode 20 | -------------------------------------------------------------------------------- /backend/README.md: -------------------------------------------------------------------------------- 1 |

Laravel Logo

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. 27 | 28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. 29 | 30 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. 31 | 32 | ## Laravel Sponsors 33 | 34 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). 35 | 36 | ### Premium Partners 37 | 38 | - **[Vehikl](https://vehikl.com/)** 39 | - **[Tighten Co.](https://tighten.co)** 40 | - **[WebReinvent](https://webreinvent.com/)** 41 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 42 | - **[64 Robots](https://64robots.com)** 43 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 44 | - **[Cyber-Duck](https://cyber-duck.co.uk)** 45 | - **[DevSquad](https://devsquad.com/hire-laravel-developers)** 46 | - **[Jump24](https://jump24.co.uk)** 47 | - **[Redberry](https://redberry.international/laravel/)** 48 | - **[Active Logic](https://activelogic.com)** 49 | - **[byte5](https://byte5.de)** 50 | - **[OP.GG](https://op.gg)** 51 | 52 | ## Contributing 53 | 54 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 55 | 56 | ## Code of Conduct 57 | 58 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). 59 | 60 | ## Security Vulnerabilities 61 | 62 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. 63 | 64 | ## License 65 | 66 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 67 | -------------------------------------------------------------------------------- /backend/_docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-fpm 2 | 3 | # Arguments defined in docker-compose.yml 4 | ARG user 5 | ARG uid 6 | 7 | # Install system dependencies 8 | RUN apt-get update && apt-get install -y \ 9 | git \ 10 | curl \ 11 | libpng-dev \ 12 | libonig-dev \ 13 | libxml2-dev \ 14 | zip \ 15 | unzip 16 | 17 | # Clear cache 18 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 19 | 20 | # Install PHP extensions 21 | RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd 22 | 23 | # Get latest Composer 24 | COPY --from=composer:latest /usr/bin/composer /usr/bin/composer 25 | 26 | # Create system user to run Composer and Artisan Commands 27 | RUN useradd -G www-data,root -u $uid -d /home/$user $user 28 | RUN mkdir -p /home/$user/.composer && \ 29 | chown -R $user:$user /home/$user 30 | 31 | COPY resources/startup.sh /usr/local/bin/startup.sh 32 | RUN chmod 644 /usr/local/bin/startup.sh 33 | 34 | # Set working directory 35 | WORKDIR /var/www/backend 36 | 37 | USER $user 38 | 39 | CMD ["sh", "/usr/local/bin/startup.sh"] 40 | -------------------------------------------------------------------------------- /backend/_docker/resources/startup.sh: -------------------------------------------------------------------------------- 1 | composer install 2 | php artisan serve --host=0.0.0.0 --port=8000 3 | -------------------------------------------------------------------------------- /backend/app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /backend/app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /backend/app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | ], 40 | 41 | 'api' => [ 42 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 43 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's middleware aliases. 50 | * 51 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. 52 | * 53 | * @var array 54 | */ 55 | protected $middlewareAliases = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, 64 | 'signed' => \App\Http\Middleware\ValidateSignature::class, 65 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 66 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 67 | ]; 68 | } 69 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /backend/app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /backend/app/Models/User.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var array 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * The attributes that should be cast. 38 | * 39 | * @var array 40 | */ 41 | protected $casts = [ 42 | 'email_verified_at' => 'datetime', 43 | 'password' => 'hashed', 44 | ]; 45 | } 46 | -------------------------------------------------------------------------------- /backend/app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /backend/app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /backend/app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /backend/artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /backend/bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /backend/bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /backend/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": ["laravel", "framework"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.1", 9 | "guzzlehttp/guzzle": "^7.2", 10 | "laravel/framework": "^10.10", 11 | "laravel/sanctum": "^3.3", 12 | "laravel/tinker": "^2.8" 13 | }, 14 | "require-dev": { 15 | "fakerphp/faker": "^1.9.1", 16 | "laravel/pint": "^1.0", 17 | "laravel/sail": "^1.18", 18 | "mockery/mockery": "^1.4.4", 19 | "nunomaduro/collision": "^7.0", 20 | "phpunit/phpunit": "^10.1", 21 | "spatie/laravel-ignition": "^2.0" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "App\\": "app/", 26 | "Database\\Factories\\": "database/factories/", 27 | "Database\\Seeders\\": "database/seeders/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Tests\\": "tests/" 33 | } 34 | }, 35 | "scripts": { 36 | "post-autoload-dump": [ 37 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 38 | "@php artisan package:discover --ansi" 39 | ], 40 | "post-update-cmd": [ 41 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 42 | ], 43 | "post-root-package-install": [ 44 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 45 | ], 46 | "post-create-project-cmd": [ 47 | "@php artisan key:generate --ansi" 48 | ] 49 | }, 50 | "extra": { 51 | "laravel": { 52 | "dont-discover": [] 53 | } 54 | }, 55 | "config": { 56 | "optimize-autoloader": true, 57 | "preferred-install": "dist", 58 | "sort-packages": true, 59 | "allow-plugins": { 60 | "pestphp/pest-plugin": true, 61 | "php-http/discovery": true 62 | } 63 | }, 64 | "minimum-stability": "stable", 65 | "prefer-stable": true 66 | } 67 | -------------------------------------------------------------------------------- /backend/config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Application Environment 24 | |-------------------------------------------------------------------------- 25 | | 26 | | This value determines the "environment" your application is currently 27 | | running in. This may determine how you prefer to configure various 28 | | services the application utilizes. Set this in your ".env" file. 29 | | 30 | */ 31 | 32 | 'env' => env('APP_ENV', 'production'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Application Debug Mode 37 | |-------------------------------------------------------------------------- 38 | | 39 | | When your application is in debug mode, detailed error messages with 40 | | stack traces will be shown on every error that occurs within your 41 | | application. If disabled, a simple generic error page is shown. 42 | | 43 | */ 44 | 45 | 'debug' => (bool) env('APP_DEBUG', false), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Application URL 50 | |-------------------------------------------------------------------------- 51 | | 52 | | This URL is used by the console to properly generate URLs when using 53 | | the Artisan command line tool. You should set this to the root of 54 | | your application so that it is used when running Artisan tasks. 55 | | 56 | */ 57 | 58 | 'url' => env('APP_URL', 'http://localhost'), 59 | 60 | 'asset_url' => env('ASSET_URL'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Application Timezone 65 | |-------------------------------------------------------------------------- 66 | | 67 | | Here you may specify the default timezone for your application, which 68 | | will be used by the PHP date and date-time functions. We have gone 69 | | ahead and set this to a sensible default for you out of the box. 70 | | 71 | */ 72 | 73 | 'timezone' => 'UTC', 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Application Locale Configuration 78 | |-------------------------------------------------------------------------- 79 | | 80 | | The application locale determines the default locale that will be used 81 | | by the translation service provider. You are free to set this value 82 | | to any of the locales which will be supported by the application. 83 | | 84 | */ 85 | 86 | 'locale' => 'en', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Application Fallback Locale 91 | |-------------------------------------------------------------------------- 92 | | 93 | | The fallback locale determines the locale to use when the current one 94 | | is not available. You may change the value to correspond to any of 95 | | the language folders that are provided through your application. 96 | | 97 | */ 98 | 99 | 'fallback_locale' => 'en', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Faker Locale 104 | |-------------------------------------------------------------------------- 105 | | 106 | | This locale will be used by the Faker PHP library when generating fake 107 | | data for your database seeds. For example, this will be used to get 108 | | localized telephone numbers, street address information and more. 109 | | 110 | */ 111 | 112 | 'faker_locale' => 'en_US', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Encryption Key 117 | |-------------------------------------------------------------------------- 118 | | 119 | | This key is used by the Illuminate encrypter service and should be set 120 | | to a random, 32 character string, otherwise these encrypted strings 121 | | will not be safe. Please do this before deploying an application! 122 | | 123 | */ 124 | 125 | 'key' => env('APP_KEY'), 126 | 127 | 'cipher' => 'AES-256-CBC', 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Maintenance Mode Driver 132 | |-------------------------------------------------------------------------- 133 | | 134 | | These configuration options determine the driver used to determine and 135 | | manage Laravel's "maintenance mode" status. The "cache" driver will 136 | | allow maintenance mode to be controlled across multiple machines. 137 | | 138 | | Supported drivers: "file", "cache" 139 | | 140 | */ 141 | 142 | 'maintenance' => [ 143 | 'driver' => 'file', 144 | // 'store' => 'redis', 145 | ], 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Autoloaded Service Providers 150 | |-------------------------------------------------------------------------- 151 | | 152 | | The service providers listed here will be automatically loaded on the 153 | | request to your application. Feel free to add your own services to 154 | | this array to grant expanded functionality to your applications. 155 | | 156 | */ 157 | 158 | 'providers' => ServiceProvider::defaultProviders()->merge([ 159 | /* 160 | * Package Service Providers... 161 | */ 162 | 163 | /* 164 | * Application Service Providers... 165 | */ 166 | App\Providers\AppServiceProvider::class, 167 | App\Providers\AuthServiceProvider::class, 168 | // App\Providers\BroadcastServiceProvider::class, 169 | App\Providers\EventServiceProvider::class, 170 | App\Providers\RouteServiceProvider::class, 171 | ])->toArray(), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | Class Aliases 176 | |-------------------------------------------------------------------------- 177 | | 178 | | This array of class aliases will be registered when this application 179 | | is started. However, feel free to register as many as you wish as 180 | | the aliases are "lazy" loaded so they don't hinder performance. 181 | | 182 | */ 183 | 184 | 'aliases' => Facade::defaultAliases()->merge([ 185 | // 'Example' => App\Facades\Example::class, 186 | ])->toArray(), 187 | 188 | ]; 189 | -------------------------------------------------------------------------------- /backend/config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication drivers have a user provider. This defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | mechanisms used by this application to persist your user's data. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | sources which represent each model / table. These sources may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => App\Models\User::class, 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | You may specify multiple password reset configurations if you have more 80 | | than one user table or model in the application and you want to have 81 | | separate password reset settings based on the specific user types. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => 'password_reset_tokens', 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | times out and the user is prompted to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => 10800, 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /backend/config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 41 | 'port' => env('PUSHER_PORT', 443), 42 | 'scheme' => env('PUSHER_SCHEME', 'https'), 43 | 'encrypted' => true, 44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 45 | ], 46 | 'client_options' => [ 47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 48 | ], 49 | ], 50 | 51 | 'ably' => [ 52 | 'driver' => 'ably', 53 | 'key' => env('ABLY_KEY'), 54 | ], 55 | 56 | 'redis' => [ 57 | 'driver' => 'redis', 58 | 'connection' => 'default', 59 | ], 60 | 61 | 'log' => [ 62 | 'driver' => 'log', 63 | ], 64 | 65 | 'null' => [ 66 | 'driver' => 'null', 67 | ], 68 | 69 | ], 70 | 71 | ]; 72 | -------------------------------------------------------------------------------- /backend/config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | 'lock_path' => storage_path('framework/cache/data'), 56 | ], 57 | 58 | 'memcached' => [ 59 | 'driver' => 'memcached', 60 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 61 | 'sasl' => [ 62 | env('MEMCACHED_USERNAME'), 63 | env('MEMCACHED_PASSWORD'), 64 | ], 65 | 'options' => [ 66 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 67 | ], 68 | 'servers' => [ 69 | [ 70 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 71 | 'port' => env('MEMCACHED_PORT', 11211), 72 | 'weight' => 100, 73 | ], 74 | ], 75 | ], 76 | 77 | 'redis' => [ 78 | 'driver' => 'redis', 79 | 'connection' => 'cache', 80 | 'lock_connection' => 'default', 81 | ], 82 | 83 | 'dynamodb' => [ 84 | 'driver' => 'dynamodb', 85 | 'key' => env('AWS_ACCESS_KEY_ID'), 86 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 87 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 88 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 89 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 90 | ], 91 | 92 | 'octane' => [ 93 | 'driver' => 'octane', 94 | ], 95 | 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Cache Key Prefix 101 | |-------------------------------------------------------------------------- 102 | | 103 | | When utilizing the APC, database, memcached, Redis, or DynamoDB cache 104 | | stores there might be other applications using the same cache. For 105 | | that reason, you may prefix every cache key to avoid collisions. 106 | | 107 | */ 108 | 109 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 110 | 111 | ]; 112 | -------------------------------------------------------------------------------- /backend/config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /backend/config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'search_path' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 93 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 94 | ], 95 | 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Migration Repository Table 101 | |-------------------------------------------------------------------------- 102 | | 103 | | This table keeps track of all the migrations that have already run for 104 | | your application. Using this information, we can determine which of 105 | | the migrations on disk haven't actually been run in the database. 106 | | 107 | */ 108 | 109 | 'migrations' => 'migrations', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Redis Databases 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Redis is an open source, fast, and advanced key-value store that also 117 | | provides a richer body of commands than a typical key-value system 118 | | such as APC or Memcached. Laravel makes it easy to dig right in. 119 | | 120 | */ 121 | 122 | 'redis' => [ 123 | 124 | 'client' => env('REDIS_CLIENT', 'phpredis'), 125 | 126 | 'options' => [ 127 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 128 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 129 | ], 130 | 131 | 'default' => [ 132 | 'url' => env('REDIS_URL'), 133 | 'host' => env('REDIS_HOST', '127.0.0.1'), 134 | 'username' => env('REDIS_USERNAME'), 135 | 'password' => env('REDIS_PASSWORD'), 136 | 'port' => env('REDIS_PORT', '6379'), 137 | 'database' => env('REDIS_DB', '0'), 138 | ], 139 | 140 | 'cache' => [ 141 | 'url' => env('REDIS_URL'), 142 | 'host' => env('REDIS_HOST', '127.0.0.1'), 143 | 'username' => env('REDIS_USERNAME'), 144 | 'password' => env('REDIS_PASSWORD'), 145 | 'port' => env('REDIS_PORT', '6379'), 146 | 'database' => env('REDIS_CACHE_DB', '1'), 147 | ], 148 | 149 | ], 150 | 151 | ]; 152 | -------------------------------------------------------------------------------- /backend/config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been set up for each driver as an example of the required values. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /backend/config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 12), 33 | 'verify' => true, 34 | ], 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Argon Options 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Here you may specify the configuration options that should be used when 42 | | passwords are hashed using the Argon algorithm. These will allow you 43 | | to control the amount of time it takes to hash the given password. 44 | | 45 | */ 46 | 47 | 'argon' => [ 48 | 'memory' => 65536, 49 | 'threads' => 1, 50 | 'time' => 4, 51 | 'verify' => true, 52 | ], 53 | 54 | ]; 55 | -------------------------------------------------------------------------------- /backend/config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => false, 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Out of 45 | | the box, Laravel uses the Monolog PHP logging library. This gives 46 | | you a variety of powerful log handlers / formatters to utilize. 47 | | 48 | | Available Drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", 50 | | "custom", "stack" 51 | | 52 | */ 53 | 54 | 'channels' => [ 55 | 'stack' => [ 56 | 'driver' => 'stack', 57 | 'channels' => ['single'], 58 | 'ignore_exceptions' => false, 59 | ], 60 | 61 | 'single' => [ 62 | 'driver' => 'single', 63 | 'path' => storage_path('logs/laravel.log'), 64 | 'level' => env('LOG_LEVEL', 'debug'), 65 | 'replace_placeholders' => true, 66 | ], 67 | 68 | 'daily' => [ 69 | 'driver' => 'daily', 70 | 'path' => storage_path('logs/laravel.log'), 71 | 'level' => env('LOG_LEVEL', 'debug'), 72 | 'days' => 14, 73 | 'replace_placeholders' => true, 74 | ], 75 | 76 | 'slack' => [ 77 | 'driver' => 'slack', 78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 79 | 'username' => 'Laravel Log', 80 | 'emoji' => ':boom:', 81 | 'level' => env('LOG_LEVEL', 'critical'), 82 | 'replace_placeholders' => true, 83 | ], 84 | 85 | 'papertrail' => [ 86 | 'driver' => 'monolog', 87 | 'level' => env('LOG_LEVEL', 'debug'), 88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 89 | 'handler_with' => [ 90 | 'host' => env('PAPERTRAIL_URL'), 91 | 'port' => env('PAPERTRAIL_PORT'), 92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 93 | ], 94 | 'processors' => [PsrLogMessageProcessor::class], 95 | ], 96 | 97 | 'stderr' => [ 98 | 'driver' => 'monolog', 99 | 'level' => env('LOG_LEVEL', 'debug'), 100 | 'handler' => StreamHandler::class, 101 | 'formatter' => env('LOG_STDERR_FORMATTER'), 102 | 'with' => [ 103 | 'stream' => 'php://stderr', 104 | ], 105 | 'processors' => [PsrLogMessageProcessor::class], 106 | ], 107 | 108 | 'syslog' => [ 109 | 'driver' => 'syslog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | 'facility' => LOG_USER, 112 | 'replace_placeholders' => true, 113 | ], 114 | 115 | 'errorlog' => [ 116 | 'driver' => 'errorlog', 117 | 'level' => env('LOG_LEVEL', 'debug'), 118 | 'replace_placeholders' => true, 119 | ], 120 | 121 | 'null' => [ 122 | 'driver' => 'monolog', 123 | 'handler' => NullHandler::class, 124 | ], 125 | 126 | 'emergency' => [ 127 | 'path' => storage_path('logs/laravel.log'), 128 | ], 129 | ], 130 | 131 | ]; 132 | -------------------------------------------------------------------------------- /backend/config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 32 | | "postmark", "log", "array", "failover", "roundrobin" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'url' => env('MAIL_URL'), 40 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 41 | 'port' => env('MAIL_PORT', 587), 42 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 43 | 'username' => env('MAIL_USERNAME'), 44 | 'password' => env('MAIL_PASSWORD'), 45 | 'timeout' => null, 46 | 'local_domain' => env('MAIL_EHLO_DOMAIN'), 47 | ], 48 | 49 | 'ses' => [ 50 | 'transport' => 'ses', 51 | ], 52 | 53 | 'postmark' => [ 54 | 'transport' => 'postmark', 55 | // 'message_stream_id' => null, 56 | // 'client' => [ 57 | // 'timeout' => 5, 58 | // ], 59 | ], 60 | 61 | 'mailgun' => [ 62 | 'transport' => 'mailgun', 63 | // 'client' => [ 64 | // 'timeout' => 5, 65 | // ], 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | ], 89 | 90 | 'roundrobin' => [ 91 | 'transport' => 'roundrobin', 92 | 'mailers' => [ 93 | 'ses', 94 | 'postmark', 95 | ], 96 | ], 97 | ], 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Global "From" Address 102 | |-------------------------------------------------------------------------- 103 | | 104 | | You may wish for all e-mails sent by your application to be sent from 105 | | the same address. Here, you may specify a name and address that is 106 | | used globally for all e-mails that are sent by your application. 107 | | 108 | */ 109 | 110 | 'from' => [ 111 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 112 | 'name' => env('MAIL_FROM_NAME', 'Example'), 113 | ], 114 | 115 | /* 116 | |-------------------------------------------------------------------------- 117 | | Markdown Mail Settings 118 | |-------------------------------------------------------------------------- 119 | | 120 | | If you are using Markdown based email rendering, you may configure your 121 | | theme and component paths here, allowing you to customize the design 122 | | of the emails. Or, you may simply stick with the Laravel defaults! 123 | | 124 | */ 125 | 126 | 'markdown' => [ 127 | 'theme' => 'default', 128 | 129 | 'paths' => [ 130 | resource_path('views/vendor/mail'), 131 | ], 132 | ], 133 | 134 | ]; 135 | -------------------------------------------------------------------------------- /backend/config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Job Batching 79 | |-------------------------------------------------------------------------- 80 | | 81 | | The following options configure the database and table that store job 82 | | batching information. These options can be updated to any database 83 | | connection and table which has been defined by your application. 84 | | 85 | */ 86 | 87 | 'batching' => [ 88 | 'database' => env('DB_CONNECTION', 'mysql'), 89 | 'table' => 'job_batches', 90 | ], 91 | 92 | /* 93 | |-------------------------------------------------------------------------- 94 | | Failed Queue Jobs 95 | |-------------------------------------------------------------------------- 96 | | 97 | | These options configure the behavior of failed queue job logging so you 98 | | can control which database and table are used to store the jobs that 99 | | have failed. You may change them to any database / table you wish. 100 | | 101 | */ 102 | 103 | 'failed' => [ 104 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 105 | 'database' => env('DB_CONNECTION', 'mysql'), 106 | 'table' => 'failed_jobs', 107 | ], 108 | 109 | ]; 110 | -------------------------------------------------------------------------------- /backend/config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. This will override any values set in the token's 45 | | "expires_at" attribute, but first-party sessions are not affected. 46 | | 47 | */ 48 | 49 | 'expiration' => null, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Token Prefix 54 | |-------------------------------------------------------------------------- 55 | | 56 | | Sanctum can prefix new tokens in order to take advantage of numerous 57 | | security scanning initiatives maintained by open source platforms 58 | | that notify developers if they commit tokens into repositories. 59 | | 60 | | See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning 61 | | 62 | */ 63 | 64 | 'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''), 65 | 66 | /* 67 | |-------------------------------------------------------------------------- 68 | | Sanctum Middleware 69 | |-------------------------------------------------------------------------- 70 | | 71 | | When authenticating your first-party SPA with Sanctum you may need to 72 | | customize some of the middleware Sanctum uses while processing the 73 | | request. You may change the middleware listed below as required. 74 | | 75 | */ 76 | 77 | 'middleware' => [ 78 | 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, 79 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 80 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 81 | ], 82 | 83 | ]; 84 | -------------------------------------------------------------------------------- /backend/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /backend/config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION'), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | While using one of the framework's cache driven session backends you may 96 | | list a cache store that should be used for these sessions. This value 97 | | must match with one of the application's configured cache "stores". 98 | | 99 | | Affects: "apc", "dynamodb", "memcached", "redis" 100 | | 101 | */ 102 | 103 | 'store' => env('SESSION_STORE'), 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Session Sweeping Lottery 108 | |-------------------------------------------------------------------------- 109 | | 110 | | Some session drivers must manually sweep their storage location to get 111 | | rid of old sessions from storage. Here are the chances that it will 112 | | happen on a given request. By default, the odds are 2 out of 100. 113 | | 114 | */ 115 | 116 | 'lottery' => [2, 100], 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Session Cookie Name 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Here you may change the name of the cookie used to identify a session 124 | | instance by ID. The name specified here will get used every time a 125 | | new session cookie is created by the framework for every driver. 126 | | 127 | */ 128 | 129 | 'cookie' => env( 130 | 'SESSION_COOKIE', 131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 132 | ), 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Session Cookie Path 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The session cookie path determines the path for which the cookie will 140 | | be regarded as available. Typically, this will be the root path of 141 | | your application but you are free to change this when necessary. 142 | | 143 | */ 144 | 145 | 'path' => '/', 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Session Cookie Domain 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Here you may change the domain of the cookie used to identify a session 153 | | in your application. This will determine which domains the cookie is 154 | | available to in your application. A sensible default has been set. 155 | | 156 | */ 157 | 158 | 'domain' => env('SESSION_DOMAIN'), 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | HTTPS Only Cookies 163 | |-------------------------------------------------------------------------- 164 | | 165 | | By setting this option to true, session cookies will only be sent back 166 | | to the server if the browser has a HTTPS connection. This will keep 167 | | the cookie from being sent to you when it can't be done securely. 168 | | 169 | */ 170 | 171 | 'secure' => env('SESSION_SECURE_COOKIE'), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | HTTP Access Only 176 | |-------------------------------------------------------------------------- 177 | | 178 | | Setting this value to true will prevent JavaScript from accessing the 179 | | value of the cookie and the cookie will only be accessible through 180 | | the HTTP protocol. You are free to modify this option if needed. 181 | | 182 | */ 183 | 184 | 'http_only' => true, 185 | 186 | /* 187 | |-------------------------------------------------------------------------- 188 | | Same-Site Cookies 189 | |-------------------------------------------------------------------------- 190 | | 191 | | This option determines how your cookies behave when cross-site requests 192 | | take place, and can be used to mitigate CSRF attacks. By default, we 193 | | will set this value to "lax" since this is a secure default value. 194 | | 195 | | Supported: "lax", "strict", "none", null 196 | | 197 | */ 198 | 199 | 'same_site' => 'lax', 200 | 201 | /* 202 | |-------------------------------------------------------------------------- 203 | | Partitioned Cookies 204 | |-------------------------------------------------------------------------- 205 | | 206 | | Setting this value to true will tie the cookie to the top-level site for 207 | | a cross-site context. Partitioned cookies are accepted by the browser 208 | | when flagged "secure" and the Same-Site attribute is set to "none". 209 | | 210 | */ 211 | 212 | 'partitioned' => false, 213 | 214 | ]; 215 | -------------------------------------------------------------------------------- /backend/config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /backend/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /backend/database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /backend/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /backend/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /backend/database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /backend/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /backend/database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | // \App\Models\User::factory()->create([ 18 | // 'name' => 'Test User', 19 | // 'email' => 'test@example.com', 20 | // ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "devDependencies": { 9 | "axios": "^1.6.1", 10 | "laravel-vite-plugin": "^1.0.0", 11 | "vite": "^5.0.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /backend/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | 16 | 17 | app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /backend/public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /backend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaminsharifi/laravel-docker-compose-dev/7c1e520bbdcdbdda19a28fe01dd81571fcb27fdd/backend/public/favicon.ico -------------------------------------------------------------------------------- /backend/public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /backend/public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /backend/resources/css/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaminsharifi/laravel-docker-compose-dev/7c1e520bbdcdbdda19a28fe01dd81571fcb27fdd/backend/resources/css/app.css -------------------------------------------------------------------------------- /backend/resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /backend/resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /backend/resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 |
20 | @if (Route::has('login')) 21 |
22 | @auth 23 | Home 24 | @else 25 | Log in 26 | 27 | @if (Route::has('register')) 28 | Register 29 | @endif 30 | @endauth 31 |
32 | @endif 33 | 34 |
35 |
36 | 37 | 38 | 39 |
40 | 41 | 120 | 121 |
122 | 132 | 133 |
134 | Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}) 135 |
136 |
137 |
138 |
139 | 140 | 141 | -------------------------------------------------------------------------------- /backend/routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /backend/routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /backend/routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /backend/routes/web.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /backend/tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertOk(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /backend/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /backend/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | laravel({ 7 | input: ['resources/css/app.css', 'resources/js/app.js'], 8 | refresh: true, 9 | }), 10 | ], 11 | }); 12 | -------------------------------------------------------------------------------- /composer-setup.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | setupEnvironment(); 14 | process(is_array($argv) ? $argv : array()); 15 | 16 | /** 17 | * Initializes various values 18 | * 19 | * @throws RuntimeException If uopz extension prevents exit calls 20 | */ 21 | function setupEnvironment() 22 | { 23 | ini_set('display_errors', 1); 24 | 25 | if (extension_loaded('uopz') && !(ini_get('uopz.disable') || ini_get('uopz.exit'))) { 26 | // uopz works at opcode level and disables exit calls 27 | if (function_exists('uopz_allow_exit')) { 28 | @uopz_allow_exit(true); 29 | } else { 30 | throw new RuntimeException('The uopz extension ignores exit calls and breaks this installer.'); 31 | } 32 | } 33 | 34 | $installer = 'ComposerInstaller'; 35 | 36 | if (defined('PHP_WINDOWS_VERSION_MAJOR')) { 37 | if ($version = getenv('COMPOSERSETUP')) { 38 | $installer = sprintf('Composer-Setup.exe/%s', $version); 39 | } 40 | } 41 | 42 | define('COMPOSER_INSTALLER', $installer); 43 | } 44 | 45 | /** 46 | * Processes the installer 47 | */ 48 | function process($argv) 49 | { 50 | // Determine ANSI output from --ansi and --no-ansi flags 51 | setUseAnsi($argv); 52 | 53 | $help = in_array('--help', $argv) || in_array('-h', $argv); 54 | if ($help) { 55 | displayHelp(); 56 | exit(0); 57 | } 58 | 59 | $check = in_array('--check', $argv); 60 | $force = in_array('--force', $argv); 61 | $quiet = in_array('--quiet', $argv); 62 | $channel = 'stable'; 63 | if (in_array('--snapshot', $argv)) { 64 | $channel = 'snapshot'; 65 | } elseif (in_array('--preview', $argv)) { 66 | $channel = 'preview'; 67 | } elseif (in_array('--1', $argv)) { 68 | $channel = '1'; 69 | } elseif (in_array('--2', $argv)) { 70 | $channel = '2'; 71 | } elseif (in_array('--2.2', $argv)) { 72 | $channel = '2.2'; 73 | } 74 | $disableTls = in_array('--disable-tls', $argv); 75 | $installDir = getOptValue('--install-dir', $argv, false); 76 | $version = getOptValue('--version', $argv, false); 77 | $filename = getOptValue('--filename', $argv, 'composer.phar'); 78 | $cafile = getOptValue('--cafile', $argv, false); 79 | 80 | if (!checkParams($installDir, $version, $cafile)) { 81 | exit(1); 82 | } 83 | 84 | $ok = checkPlatform($warnings, $quiet, $disableTls, true); 85 | 86 | if ($check) { 87 | // Only show warnings if we haven't output any errors 88 | if ($ok) { 89 | showWarnings($warnings); 90 | showSecurityWarning($disableTls); 91 | } 92 | exit($ok ? 0 : 1); 93 | } 94 | 95 | if ($ok || $force) { 96 | if ($channel === '1' && !$quiet) { 97 | out('Warning: You forced the install of Composer 1.x via --1, but Composer 2.x is the latest stable version. Updating to it via composer self-update --stable is recommended.', 'error'); 98 | } 99 | 100 | $installer = new Installer($quiet, $disableTls, $cafile); 101 | if ($installer->run($version, $installDir, $filename, $channel)) { 102 | showWarnings($warnings); 103 | showSecurityWarning($disableTls); 104 | exit(0); 105 | } 106 | } 107 | 108 | exit(1); 109 | } 110 | 111 | /** 112 | * Displays the help 113 | */ 114 | function displayHelp() 115 | { 116 | echo << $value) { 207 | $next = $key + 1; 208 | if (0 === strpos($value, $opt)) { 209 | if ($optLength === strlen($value) && isset($argv[$next])) { 210 | return trim($argv[$next]); 211 | } else { 212 | return trim(substr($value, $optLength + 1)); 213 | } 214 | } 215 | } 216 | 217 | return $default; 218 | } 219 | 220 | /** 221 | * Checks that user-supplied params are valid 222 | * 223 | * @param mixed $installDir The required istallation directory 224 | * @param mixed $version The required composer version to install 225 | * @param mixed $cafile Certificate Authority file 226 | * 227 | * @return bool True if the supplied params are okay 228 | */ 229 | function checkParams($installDir, $version, $cafile) 230 | { 231 | $result = true; 232 | 233 | if (false !== $installDir && !is_dir($installDir)) { 234 | out("The defined install dir ({$installDir}) does not exist.", 'info'); 235 | $result = false; 236 | } 237 | 238 | if (false !== $version && 1 !== preg_match('/^\d+\.\d+\.\d+(\-(alpha|beta|RC)\d*)*$/', $version)) { 239 | out("The defined install version ({$version}) does not match release pattern.", 'info'); 240 | $result = false; 241 | } 242 | 243 | if (false !== $cafile && (!file_exists($cafile) || !is_readable($cafile))) { 244 | out("The defined Certificate Authority (CA) cert file ({$cafile}) does not exist or is not readable.", 'info'); 245 | $result = false; 246 | } 247 | return $result; 248 | } 249 | 250 | /** 251 | * Checks the platform for possible issues running Composer 252 | * 253 | * Errors are written to the output, warnings are saved for later display. 254 | * 255 | * @param array $warnings Populated by method, to be shown later 256 | * @param bool $quiet Quiet mode 257 | * @param bool $disableTls Bypass tls 258 | * @param bool $install If we are installing, rather than diagnosing 259 | * 260 | * @return bool True if there are no errors 261 | */ 262 | function checkPlatform(&$warnings, $quiet, $disableTls, $install) 263 | { 264 | getPlatformIssues($errors, $warnings, $install); 265 | 266 | // Make openssl warning an error if tls has not been specifically disabled 267 | if (isset($warnings['openssl']) && !$disableTls) { 268 | $errors['openssl'] = $warnings['openssl']; 269 | unset($warnings['openssl']); 270 | } 271 | 272 | if (!empty($errors)) { 273 | // Composer-Setup.exe uses "Some settings" to flag platform errors 274 | out('Some settings on your machine make Composer unable to work properly.', 'error'); 275 | out('Make sure that you fix the issues listed below and run this script again:', 'error'); 276 | outputIssues($errors); 277 | return false; 278 | } 279 | 280 | if (empty($warnings) && !$quiet) { 281 | out('All settings correct for using Composer', 'success'); 282 | } 283 | return true; 284 | } 285 | 286 | /** 287 | * Checks platform configuration for common incompatibility issues 288 | * 289 | * @param array $errors Populated by method 290 | * @param array $warnings Populated by method 291 | * @param bool $install If we are installing, rather than diagnosing 292 | * 293 | * @return bool If any errors or warnings have been found 294 | */ 295 | function getPlatformIssues(&$errors, &$warnings, $install) 296 | { 297 | $errors = array(); 298 | $warnings = array(); 299 | 300 | if ($iniPath = php_ini_loaded_file()) { 301 | $iniMessage = PHP_EOL.'The php.ini used by your command-line PHP is: ' . $iniPath; 302 | } else { 303 | $iniMessage = PHP_EOL.'A php.ini file does not exist. You will have to create one.'; 304 | } 305 | $iniMessage .= PHP_EOL.'If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.'; 306 | 307 | if (ini_get('detect_unicode')) { 308 | $errors['unicode'] = array( 309 | 'The detect_unicode setting must be disabled.', 310 | 'Add the following to the end of your `php.ini`:', 311 | ' detect_unicode = Off', 312 | $iniMessage 313 | ); 314 | } 315 | 316 | if (extension_loaded('suhosin')) { 317 | $suhosin = ini_get('suhosin.executor.include.whitelist'); 318 | $suhosinBlacklist = ini_get('suhosin.executor.include.blacklist'); 319 | if (false === stripos($suhosin, 'phar') && (!$suhosinBlacklist || false !== stripos($suhosinBlacklist, 'phar'))) { 320 | $errors['suhosin'] = array( 321 | 'The suhosin.executor.include.whitelist setting is incorrect.', 322 | 'Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):', 323 | ' suhosin.executor.include.whitelist = phar '.$suhosin, 324 | $iniMessage 325 | ); 326 | } 327 | } 328 | 329 | if (!function_exists('json_decode')) { 330 | $errors['json'] = array( 331 | 'The json extension is missing.', 332 | 'Install it or recompile php without --disable-json' 333 | ); 334 | } 335 | 336 | if (!extension_loaded('Phar')) { 337 | $errors['phar'] = array( 338 | 'The phar extension is missing.', 339 | 'Install it or recompile php without --disable-phar' 340 | ); 341 | } 342 | 343 | if (!extension_loaded('filter')) { 344 | $errors['filter'] = array( 345 | 'The filter extension is missing.', 346 | 'Install it or recompile php without --disable-filter' 347 | ); 348 | } 349 | 350 | if (!extension_loaded('hash')) { 351 | $errors['hash'] = array( 352 | 'The hash extension is missing.', 353 | 'Install it or recompile php without --disable-hash' 354 | ); 355 | } 356 | 357 | if (!extension_loaded('iconv') && !extension_loaded('mbstring')) { 358 | $errors['iconv_mbstring'] = array( 359 | 'The iconv OR mbstring extension is required and both are missing.', 360 | 'Install either of them or recompile php without --disable-iconv' 361 | ); 362 | } 363 | 364 | if (!ini_get('allow_url_fopen')) { 365 | $errors['allow_url_fopen'] = array( 366 | 'The allow_url_fopen setting is incorrect.', 367 | 'Add the following to the end of your `php.ini`:', 368 | ' allow_url_fopen = On', 369 | $iniMessage 370 | ); 371 | } 372 | 373 | if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) { 374 | $ioncube = ioncube_loader_version(); 375 | $errors['ioncube'] = array( 376 | 'Your ionCube Loader extension ('.$ioncube.') is incompatible with Phar files.', 377 | 'Upgrade to ionCube 4.0.9 or higher or remove this line (path may be different) from your `php.ini` to disable it:', 378 | ' zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so', 379 | $iniMessage 380 | ); 381 | } 382 | 383 | if (version_compare(PHP_VERSION, '5.3.2', '<')) { 384 | $errors['php'] = array( 385 | 'Your PHP ('.PHP_VERSION.') is too old, you must upgrade to PHP 5.3.2 or higher.' 386 | ); 387 | } 388 | 389 | if (version_compare(PHP_VERSION, '5.3.4', '<')) { 390 | $warnings['php'] = array( 391 | 'Your PHP ('.PHP_VERSION.') is quite old, upgrading to PHP 5.3.4 or higher is recommended.', 392 | 'Composer works with 5.3.2+ for most people, but there might be edge case issues.' 393 | ); 394 | } 395 | 396 | if (!extension_loaded('openssl')) { 397 | $warnings['openssl'] = array( 398 | 'The openssl extension is missing, which means that secure HTTPS transfers are impossible.', 399 | 'If possible you should enable it or recompile php with --with-openssl' 400 | ); 401 | } 402 | 403 | if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) { 404 | // Attempt to parse version number out, fallback to whole string value. 405 | $opensslVersion = trim(strstr(OPENSSL_VERSION_TEXT, ' ')); 406 | $opensslVersion = substr($opensslVersion, 0, strpos($opensslVersion, ' ')); 407 | $opensslVersion = $opensslVersion ? $opensslVersion : OPENSSL_VERSION_TEXT; 408 | 409 | $warnings['openssl_version'] = array( 410 | 'The OpenSSL library ('.$opensslVersion.') used by PHP does not support TLSv1.2 or TLSv1.1.', 411 | 'If possible you should upgrade OpenSSL to version 1.0.1 or above.' 412 | ); 413 | } 414 | 415 | if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) { 416 | $warnings['apc_cli'] = array( 417 | 'The apc.enable_cli setting is incorrect.', 418 | 'Add the following to the end of your `php.ini`:', 419 | ' apc.enable_cli = Off', 420 | $iniMessage 421 | ); 422 | } 423 | 424 | if (!$install && extension_loaded('xdebug')) { 425 | $warnings['xdebug_loaded'] = array( 426 | 'The xdebug extension is loaded, this can slow down Composer a little.', 427 | 'Disabling it when using Composer is recommended.' 428 | ); 429 | 430 | if (ini_get('xdebug.profiler_enabled')) { 431 | $warnings['xdebug_profile'] = array( 432 | 'The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.', 433 | 'Add the following to the end of your `php.ini` to disable it:', 434 | ' xdebug.profiler_enabled = 0', 435 | $iniMessage 436 | ); 437 | } 438 | } 439 | 440 | if (!extension_loaded('zlib')) { 441 | $warnings['zlib'] = array( 442 | 'The zlib extension is not loaded, this can slow down Composer a lot.', 443 | 'If possible, install it or recompile php with --with-zlib', 444 | $iniMessage 445 | ); 446 | } 447 | 448 | if (defined('PHP_WINDOWS_VERSION_BUILD') 449 | && (version_compare(PHP_VERSION, '7.2.23', '<') 450 | || (version_compare(PHP_VERSION, '7.3.0', '>=') 451 | && version_compare(PHP_VERSION, '7.3.10', '<')))) { 452 | $warnings['onedrive'] = array( 453 | 'The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.', 454 | 'Upgrade your PHP ('.PHP_VERSION.') to use this location with Composer.' 455 | ); 456 | } 457 | 458 | if (extension_loaded('uopz') && !(ini_get('uopz.disable') || ini_get('uopz.exit'))) { 459 | $warnings['uopz'] = array( 460 | 'The uopz extension ignores exit calls and may not work with all Composer commands.', 461 | 'Disabling it when using Composer is recommended.' 462 | ); 463 | } 464 | 465 | ob_start(); 466 | phpinfo(INFO_GENERAL); 467 | $phpinfo = ob_get_clean(); 468 | if (preg_match('{Configure Command(?: *| *=> *)(.*?)(?:|$)}m', $phpinfo, $match)) { 469 | $configure = $match[1]; 470 | 471 | if (false !== strpos($configure, '--enable-sigchild')) { 472 | $warnings['sigchild'] = array( 473 | 'PHP was compiled with --enable-sigchild which can cause issues on some platforms.', 474 | 'Recompile it without this flag if possible, see also:', 475 | ' https://bugs.php.net/bug.php?id=22999' 476 | ); 477 | } 478 | 479 | if (false !== strpos($configure, '--with-curlwrappers')) { 480 | $warnings['curlwrappers'] = array( 481 | 'PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.', 482 | 'Recompile it without this flag if possible' 483 | ); 484 | } 485 | } 486 | 487 | // Stringify the message arrays 488 | foreach ($errors as $key => $value) { 489 | $errors[$key] = PHP_EOL.implode(PHP_EOL, $value); 490 | } 491 | 492 | foreach ($warnings as $key => $value) { 493 | $warnings[$key] = PHP_EOL.implode(PHP_EOL, $value); 494 | } 495 | 496 | return !empty($errors) || !empty($warnings); 497 | } 498 | 499 | 500 | /** 501 | * Outputs an array of issues 502 | * 503 | * @param array $issues 504 | */ 505 | function outputIssues($issues) 506 | { 507 | foreach ($issues as $issue) { 508 | out($issue, 'info'); 509 | } 510 | out(''); 511 | } 512 | 513 | /** 514 | * Outputs any warnings found 515 | * 516 | * @param array $warnings 517 | */ 518 | function showWarnings($warnings) 519 | { 520 | if (!empty($warnings)) { 521 | out('Some settings on your machine may cause stability issues with Composer.', 'error'); 522 | out('If you encounter issues, try to change the following:', 'error'); 523 | outputIssues($warnings); 524 | } 525 | } 526 | 527 | /** 528 | * Outputs an end of process warning if tls has been bypassed 529 | * 530 | * @param bool $disableTls Bypass tls 531 | */ 532 | function showSecurityWarning($disableTls) 533 | { 534 | if ($disableTls) { 535 | out('You have instructed the Installer not to enforce SSL/TLS security on remote HTTPS requests.', 'info'); 536 | out('This will leave all downloads during installation vulnerable to Man-In-The-Middle (MITM) attacks', 'info'); 537 | } 538 | } 539 | 540 | /** 541 | * colorize output 542 | */ 543 | function out($text, $color = null, $newLine = true) 544 | { 545 | $styles = array( 546 | 'success' => "\033[0;32m%s\033[0m", 547 | 'error' => "\033[31;31m%s\033[0m", 548 | 'info' => "\033[33;33m%s\033[0m" 549 | ); 550 | 551 | $format = '%s'; 552 | 553 | if (isset($styles[$color]) && USE_ANSI) { 554 | $format = $styles[$color]; 555 | } 556 | 557 | if ($newLine) { 558 | $format .= PHP_EOL; 559 | } 560 | 561 | printf($format, $text); 562 | } 563 | 564 | /** 565 | * Returns the system-dependent Composer home location, which may not exist 566 | * 567 | * @return string 568 | */ 569 | function getHomeDir() 570 | { 571 | $home = getenv('COMPOSER_HOME'); 572 | if ($home) { 573 | return $home; 574 | } 575 | 576 | $userDir = getUserDir(); 577 | 578 | if (defined('PHP_WINDOWS_VERSION_MAJOR')) { 579 | return $userDir.'/Composer'; 580 | } 581 | 582 | $dirs = array(); 583 | 584 | if (useXdg()) { 585 | // XDG Base Directory Specifications 586 | $xdgConfig = getenv('XDG_CONFIG_HOME'); 587 | if (!$xdgConfig) { 588 | $xdgConfig = $userDir . '/.config'; 589 | } 590 | 591 | $dirs[] = $xdgConfig . '/composer'; 592 | } 593 | 594 | $dirs[] = $userDir . '/.composer'; 595 | 596 | // select first dir which exists of: $XDG_CONFIG_HOME/composer or ~/.composer 597 | foreach ($dirs as $dir) { 598 | if (is_dir($dir)) { 599 | return $dir; 600 | } 601 | } 602 | 603 | // if none exists, we default to first defined one (XDG one if system uses it, or ~/.composer otherwise) 604 | return $dirs[0]; 605 | } 606 | 607 | /** 608 | * Returns the location of the user directory from the environment 609 | * @throws RuntimeException If the environment value does not exists 610 | * 611 | * @return string 612 | */ 613 | function getUserDir() 614 | { 615 | $userEnv = defined('PHP_WINDOWS_VERSION_MAJOR') ? 'APPDATA' : 'HOME'; 616 | $userDir = getenv($userEnv); 617 | 618 | if (!$userDir) { 619 | throw new RuntimeException('The '.$userEnv.' or COMPOSER_HOME environment variable must be set for composer to run correctly'); 620 | } 621 | 622 | return rtrim(strtr($userDir, '\\', '/'), '/'); 623 | } 624 | 625 | /** 626 | * @return bool 627 | */ 628 | function useXdg() 629 | { 630 | foreach (array_keys($_SERVER) as $key) { 631 | if (strpos($key, 'XDG_') === 0) { 632 | return true; 633 | } 634 | } 635 | 636 | if (is_dir('/etc/xdg')) { 637 | return true; 638 | } 639 | 640 | return false; 641 | } 642 | 643 | function validateCaFile($contents) 644 | { 645 | // assume the CA is valid if php is vulnerable to 646 | // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html 647 | if ( 648 | PHP_VERSION_ID <= 50327 649 | || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50422) 650 | || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50506) 651 | ) { 652 | return !empty($contents); 653 | } 654 | 655 | return (bool) openssl_x509_parse($contents); 656 | } 657 | 658 | class Installer 659 | { 660 | private $quiet; 661 | private $disableTls; 662 | private $cafile; 663 | private $displayPath; 664 | private $target; 665 | private $tmpFile; 666 | private $tmpCafile; 667 | private $baseUrl; 668 | private $algo; 669 | private $errHandler; 670 | private $httpClient; 671 | private $pubKeys = array(); 672 | private $installs = array(); 673 | 674 | /** 675 | * Constructor - must not do anything that throws an exception 676 | * 677 | * @param bool $quiet Quiet mode 678 | * @param bool $disableTls Bypass tls 679 | * @param mixed $cafile Path to CA bundle, or false 680 | */ 681 | public function __construct($quiet, $disableTls, $caFile) 682 | { 683 | if (($this->quiet = $quiet)) { 684 | ob_start(); 685 | } 686 | $this->disableTls = $disableTls; 687 | $this->cafile = $caFile; 688 | $this->errHandler = new ErrorHandler(); 689 | } 690 | 691 | /** 692 | * Runs the installer 693 | * 694 | * @param mixed $version Specific version to install, or false 695 | * @param mixed $installDir Specific installation directory, or false 696 | * @param string $filename Specific filename to save to, or composer.phar 697 | * @param string $channel Specific version channel to use 698 | * @throws Exception If anything other than a RuntimeException is caught 699 | * 700 | * @return bool If the installation succeeded 701 | */ 702 | public function run($version, $installDir, $filename, $channel) 703 | { 704 | try { 705 | $this->initTargets($installDir, $filename); 706 | $this->initTls(); 707 | $this->httpClient = new HttpClient($this->disableTls, $this->cafile); 708 | $result = $this->install($version, $channel); 709 | 710 | // in case --1 or --2 is passed, we leave the default channel for next self-update to stable 711 | if (1 === preg_match('{^\d+$}D', $channel)) { 712 | $channel = 'stable'; 713 | } 714 | 715 | if ($result && $channel !== 'stable' && !$version && defined('PHP_BINARY')) { 716 | $null = (defined('PHP_WINDOWS_VERSION_MAJOR') ? 'NUL' : '/dev/null'); 717 | @exec(escapeshellarg(PHP_BINARY) .' '.escapeshellarg($this->target).' self-update --'.$channel.' --set-channel-only -q > '.$null.' 2> '.$null, $output); 718 | } 719 | } catch (Exception $e) { 720 | $result = false; 721 | } 722 | 723 | // Always clean up 724 | $this->cleanUp($result); 725 | 726 | if (isset($e)) { 727 | // Rethrow anything that is not a RuntimeException 728 | if (!$e instanceof RuntimeException) { 729 | throw $e; 730 | } 731 | out($e->getMessage(), 'error'); 732 | } 733 | return $result; 734 | } 735 | 736 | /** 737 | * Initialization methods to set the required filenames and composer url 738 | * 739 | * @param mixed $installDir Specific installation directory, or false 740 | * @param string $filename Specific filename to save to, or composer.phar 741 | * @throws RuntimeException If the installation directory is not writable 742 | */ 743 | protected function initTargets($installDir, $filename) 744 | { 745 | $this->displayPath = ($installDir ? rtrim($installDir, '/').'/' : '').$filename; 746 | $installDir = $installDir ? realpath($installDir) : getcwd(); 747 | 748 | if (!is_writeable($installDir)) { 749 | throw new RuntimeException('The installation directory "'.$installDir.'" is not writable'); 750 | } 751 | 752 | $this->target = $installDir.DIRECTORY_SEPARATOR.$filename; 753 | $this->tmpFile = $installDir.DIRECTORY_SEPARATOR.basename($this->target, '.phar').'-temp.phar'; 754 | 755 | $uriScheme = $this->disableTls ? 'http' : 'https'; 756 | $this->baseUrl = $uriScheme.'://getcomposer.org'; 757 | } 758 | 759 | /** 760 | * A wrapper around methods to check tls and write public keys 761 | * @throws RuntimeException If SHA384 is not supported 762 | */ 763 | protected function initTls() 764 | { 765 | if ($this->disableTls) { 766 | return; 767 | } 768 | 769 | if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) { 770 | throw new RuntimeException('SHA384 is not supported by your openssl extension'); 771 | } 772 | 773 | $this->algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384'; 774 | $home = $this->getComposerHome(); 775 | 776 | $this->pubKeys = array( 777 | 'dev' => $this->installKey(self::getPKDev(), $home, 'keys.dev.pub'), 778 | 'tags' => $this->installKey(self::getPKTags(), $home, 'keys.tags.pub') 779 | ); 780 | 781 | if (empty($this->cafile) && !HttpClient::getSystemCaRootBundlePath()) { 782 | $this->cafile = $this->tmpCafile = $this->installKey(HttpClient::getPackagedCaFile(), $home, 'cacert-temp.pem'); 783 | } 784 | } 785 | 786 | /** 787 | * Returns the Composer home directory, creating it if required 788 | * @throws RuntimeException If the directory cannot be created 789 | * 790 | * @return string 791 | */ 792 | protected function getComposerHome() 793 | { 794 | $home = getHomeDir(); 795 | 796 | if (!is_dir($home)) { 797 | $this->errHandler->start(); 798 | 799 | if (!mkdir($home, 0777, true)) { 800 | throw new RuntimeException(sprintf( 801 | 'Unable to create Composer home directory "%s": %s', 802 | $home, 803 | $this->errHandler->message 804 | )); 805 | } 806 | $this->installs[] = $home; 807 | $this->errHandler->stop(); 808 | } 809 | return $home; 810 | } 811 | 812 | /** 813 | * Writes public key data to disc 814 | * 815 | * @param string $data The public key(s) in pem format 816 | * @param string $path The directory to write to 817 | * @param string $filename The name of the file 818 | * @throws RuntimeException If the file cannot be written 819 | * 820 | * @return string The path to the saved data 821 | */ 822 | protected function installKey($data, $path, $filename) 823 | { 824 | $this->errHandler->start(); 825 | 826 | $target = $path.DIRECTORY_SEPARATOR.$filename; 827 | $installed = file_exists($target); 828 | $write = file_put_contents($target, $data, LOCK_EX); 829 | @chmod($target, 0644); 830 | 831 | $this->errHandler->stop(); 832 | 833 | if (!$write) { 834 | throw new RuntimeException(sprintf('Unable to write %s to: %s', $filename, $path)); 835 | } 836 | 837 | if (!$installed) { 838 | $this->installs[] = $target; 839 | } 840 | 841 | return $target; 842 | } 843 | 844 | /** 845 | * The main install function 846 | * 847 | * @param mixed $version Specific version to install, or false 848 | * @param string $channel Version channel to use 849 | * 850 | * @return bool If the installation succeeded 851 | */ 852 | protected function install($version, $channel) 853 | { 854 | $retries = 3; 855 | $result = false; 856 | $infoMsg = 'Downloading...'; 857 | $infoType = 'info'; 858 | 859 | while ($retries--) { 860 | if (!$this->quiet) { 861 | out($infoMsg, $infoType); 862 | $infoMsg = 'Retrying...'; 863 | $infoType = 'error'; 864 | } 865 | 866 | if (!$this->getVersion($channel, $version, $url, $error)) { 867 | out($error, 'error'); 868 | continue; 869 | } 870 | 871 | if (!$this->downloadToTmp($url, $signature, $error)) { 872 | out($error, 'error'); 873 | continue; 874 | } 875 | 876 | if (!$this->verifyAndSave($version, $signature, $error)) { 877 | out($error, 'error'); 878 | continue; 879 | } 880 | 881 | $result = true; 882 | break; 883 | } 884 | 885 | if (!$this->quiet) { 886 | if ($result) { 887 | out(PHP_EOL."Composer (version {$version}) successfully installed to: {$this->target}", 'success'); 888 | out("Use it: php {$this->displayPath}", 'info'); 889 | out(''); 890 | } else { 891 | out('The download failed repeatedly, aborting.', 'error'); 892 | } 893 | } 894 | return $result; 895 | } 896 | 897 | /** 898 | * Sets the version url, downloading version data if required 899 | * 900 | * @param string $channel Version channel to use 901 | * @param false|string $version Version to install, or set by method 902 | * @param null|string $url The versioned url, set by method 903 | * @param null|string $error Set by method on failure 904 | * 905 | * @return bool If the operation succeeded 906 | */ 907 | protected function getVersion($channel, &$version, &$url, &$error) 908 | { 909 | $error = ''; 910 | 911 | if ($version) { 912 | if (empty($url)) { 913 | $url = $this->baseUrl."/download/{$version}/composer.phar"; 914 | } 915 | return true; 916 | } 917 | 918 | $this->errHandler->start(); 919 | 920 | if ($this->downloadVersionData($data, $error)) { 921 | $this->parseVersionData($data, $channel, $version, $url); 922 | } 923 | 924 | $this->errHandler->stop(); 925 | return empty($error); 926 | } 927 | 928 | /** 929 | * Downloads and json-decodes version data 930 | * 931 | * @param null|array $data Downloaded version data, set by method 932 | * @param null|string $error Set by method on failure 933 | * 934 | * @return bool If the operation succeeded 935 | */ 936 | protected function downloadVersionData(&$data, &$error) 937 | { 938 | $url = $this->baseUrl.'/versions'; 939 | $errFmt = 'The "%s" file could not be %s: %s'; 940 | 941 | if (!$json = $this->httpClient->get($url)) { 942 | $error = sprintf($errFmt, $url, 'downloaded', $this->errHandler->message); 943 | return false; 944 | } 945 | 946 | if (!$data = json_decode($json, true)) { 947 | $error = sprintf($errFmt, $url, 'json-decoded', $this->getJsonError()); 948 | return false; 949 | } 950 | return true; 951 | } 952 | 953 | /** 954 | * A wrapper around the methods needed to download and save the phar 955 | * 956 | * @param string $url The versioned download url 957 | * @param null|string $signature Set by method on successful download 958 | * @param null|string $error Set by method on failure 959 | * 960 | * @return bool If the operation succeeded 961 | */ 962 | protected function downloadToTmp($url, &$signature, &$error) 963 | { 964 | $error = ''; 965 | $errFmt = 'The "%s" file could not be downloaded: %s'; 966 | $sigUrl = $url.'.sig'; 967 | $this->errHandler->start(); 968 | 969 | if (!$fh = fopen($this->tmpFile, 'w')) { 970 | $error = sprintf('Could not create file "%s": %s', $this->tmpFile, $this->errHandler->message); 971 | 972 | } elseif (!$this->getSignature($sigUrl, $signature)) { 973 | $error = sprintf($errFmt, $sigUrl, $this->errHandler->message); 974 | 975 | } elseif (!fwrite($fh, $this->httpClient->get($url))) { 976 | $error = sprintf($errFmt, $url, $this->errHandler->message); 977 | } 978 | 979 | if (is_resource($fh)) { 980 | fclose($fh); 981 | } 982 | $this->errHandler->stop(); 983 | return empty($error); 984 | } 985 | 986 | /** 987 | * Verifies the downloaded file and saves it to the target location 988 | * 989 | * @param string $version The composer version downloaded 990 | * @param string $signature The digital signature to check 991 | * @param null|string $error Set by method on failure 992 | * 993 | * @return bool If the operation succeeded 994 | */ 995 | protected function verifyAndSave($version, $signature, &$error) 996 | { 997 | $error = ''; 998 | 999 | if (!$this->validatePhar($this->tmpFile, $pharError)) { 1000 | $error = 'The download is corrupt: '.$pharError; 1001 | 1002 | } elseif (!$this->verifySignature($version, $signature, $this->tmpFile)) { 1003 | $error = 'Signature mismatch, could not verify the phar file integrity'; 1004 | 1005 | } else { 1006 | $this->errHandler->start(); 1007 | 1008 | if (!rename($this->tmpFile, $this->target)) { 1009 | $error = sprintf('Could not write to file "%s": %s', $this->target, $this->errHandler->message); 1010 | } 1011 | chmod($this->target, 0755); 1012 | $this->errHandler->stop(); 1013 | } 1014 | 1015 | return empty($error); 1016 | } 1017 | 1018 | /** 1019 | * Parses an array of version data to match the required channel 1020 | * 1021 | * @param array $data Downloaded version data 1022 | * @param mixed $channel Version channel to use 1023 | * @param false|string $version Set by method 1024 | * @param mixed $url The versioned url, set by method 1025 | */ 1026 | protected function parseVersionData(array $data, $channel, &$version, &$url) 1027 | { 1028 | foreach ($data[$channel] as $candidate) { 1029 | if ($candidate['min-php'] <= PHP_VERSION_ID) { 1030 | $version = $candidate['version']; 1031 | $url = $this->baseUrl.$candidate['path']; 1032 | break; 1033 | } 1034 | } 1035 | 1036 | if (!$version) { 1037 | $error = sprintf( 1038 | 'None of the %d %s version(s) of Composer matches your PHP version (%s / ID: %d)', 1039 | count($data[$channel]), 1040 | $channel, 1041 | PHP_VERSION, 1042 | PHP_VERSION_ID 1043 | ); 1044 | throw new RuntimeException($error); 1045 | } 1046 | } 1047 | 1048 | /** 1049 | * Downloads the digital signature of required phar file 1050 | * 1051 | * @param string $url The signature url 1052 | * @param null|string $signature Set by method on success 1053 | * 1054 | * @return bool If the download succeeded 1055 | */ 1056 | protected function getSignature($url, &$signature) 1057 | { 1058 | if (!$result = $this->disableTls) { 1059 | $signature = $this->httpClient->get($url); 1060 | 1061 | if ($signature) { 1062 | $signature = json_decode($signature, true); 1063 | $signature = base64_decode($signature['sha384']); 1064 | $result = true; 1065 | } 1066 | } 1067 | 1068 | return $result; 1069 | } 1070 | 1071 | /** 1072 | * Verifies the signature of the downloaded phar 1073 | * 1074 | * @param string $version The composer versione 1075 | * @param string $signature The downloaded digital signature 1076 | * @param string $file The temp phar file 1077 | * 1078 | * @return bool If the operation succeeded 1079 | */ 1080 | protected function verifySignature($version, $signature, $file) 1081 | { 1082 | if (!$result = $this->disableTls) { 1083 | $path = preg_match('{^[0-9a-f]{40}$}', $version) ? $this->pubKeys['dev'] : $this->pubKeys['tags']; 1084 | $pubkeyid = openssl_pkey_get_public('file://'.$path); 1085 | 1086 | $result = 1 === openssl_verify( 1087 | file_get_contents($file), 1088 | $signature, 1089 | $pubkeyid, 1090 | $this->algo 1091 | ); 1092 | 1093 | // PHP 8 automatically frees the key instance and deprecates the function 1094 | if (PHP_VERSION_ID < 80000) { 1095 | openssl_free_key($pubkeyid); 1096 | } 1097 | } 1098 | 1099 | return $result; 1100 | } 1101 | 1102 | /** 1103 | * Validates the downloaded phar file 1104 | * 1105 | * @param string $pharFile The temp phar file 1106 | * @param null|string $error Set by method on failure 1107 | * 1108 | * @return bool If the operation succeeded 1109 | */ 1110 | protected function validatePhar($pharFile, &$error) 1111 | { 1112 | if (ini_get('phar.readonly')) { 1113 | return true; 1114 | } 1115 | 1116 | try { 1117 | // Test the phar validity 1118 | $phar = new Phar($pharFile); 1119 | // Free the variable to unlock the file 1120 | unset($phar); 1121 | $result = true; 1122 | 1123 | } catch (Exception $e) { 1124 | if (!$e instanceof UnexpectedValueException && !$e instanceof PharException) { 1125 | throw $e; 1126 | } 1127 | $error = $e->getMessage(); 1128 | $result = false; 1129 | } 1130 | return $result; 1131 | } 1132 | 1133 | /** 1134 | * Returns a string representation of the last json error 1135 | * 1136 | * @return string The error string or code 1137 | */ 1138 | protected function getJsonError() 1139 | { 1140 | if (function_exists('json_last_error_msg')) { 1141 | return json_last_error_msg(); 1142 | } else { 1143 | return 'json_last_error = '.json_last_error(); 1144 | } 1145 | } 1146 | 1147 | /** 1148 | * Cleans up resources at the end of the installation 1149 | * 1150 | * @param bool $result If the installation succeeded 1151 | */ 1152 | protected function cleanUp($result) 1153 | { 1154 | if (!$result) { 1155 | // Output buffered errors 1156 | if ($this->quiet) { 1157 | $this->outputErrors(); 1158 | } 1159 | // Clean up stuff we created 1160 | $this->uninstall(); 1161 | } elseif ($this->tmpCafile) { 1162 | @unlink($this->tmpCafile); 1163 | } 1164 | } 1165 | 1166 | /** 1167 | * Outputs unique errors when in quiet mode 1168 | * 1169 | */ 1170 | protected function outputErrors() 1171 | { 1172 | $errors = explode(PHP_EOL, ob_get_clean()); 1173 | $shown = array(); 1174 | 1175 | foreach ($errors as $error) { 1176 | if ($error && !in_array($error, $shown)) { 1177 | out($error, 'error'); 1178 | $shown[] = $error; 1179 | } 1180 | } 1181 | } 1182 | 1183 | /** 1184 | * Uninstalls newly-created files and directories on failure 1185 | * 1186 | */ 1187 | protected function uninstall() 1188 | { 1189 | foreach (array_reverse($this->installs) as $target) { 1190 | if (is_file($target)) { 1191 | @unlink($target); 1192 | } elseif (is_dir($target)) { 1193 | @rmdir($target); 1194 | } 1195 | } 1196 | 1197 | if ($this->tmpFile !== null && file_exists($this->tmpFile)) { 1198 | @unlink($this->tmpFile); 1199 | } 1200 | } 1201 | 1202 | public static function getPKDev() 1203 | { 1204 | return <<message) { 1257 | $this->message .= PHP_EOL; 1258 | } 1259 | $this->message .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg); 1260 | } 1261 | 1262 | /** 1263 | * Starts error-handling if not already active 1264 | * 1265 | * Any message is cleared 1266 | */ 1267 | public function start() 1268 | { 1269 | if (!$this->active) { 1270 | set_error_handler(array($this, 'handleError')); 1271 | $this->active = true; 1272 | } 1273 | $this->message = ''; 1274 | } 1275 | 1276 | /** 1277 | * Stops error-handling if active 1278 | * 1279 | * Any message is preserved until the next call to start() 1280 | */ 1281 | public function stop() 1282 | { 1283 | if ($this->active) { 1284 | restore_error_handler(); 1285 | $this->active = false; 1286 | } 1287 | } 1288 | } 1289 | 1290 | class NoProxyPattern 1291 | { 1292 | private $composerInNoProxy = false; 1293 | private $rulePorts = array(); 1294 | 1295 | public function __construct($pattern) 1296 | { 1297 | $rules = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY); 1298 | 1299 | if ($matches = preg_grep('{getcomposer\.org(?::\d+)?}i', $rules)) { 1300 | $this->composerInNoProxy = true; 1301 | 1302 | foreach ($matches as $match) { 1303 | if (strpos($match, ':') !== false) { 1304 | list(, $port) = explode(':', $match); 1305 | $this->rulePorts[] = (int) $port; 1306 | } 1307 | } 1308 | } 1309 | } 1310 | 1311 | /** 1312 | * Returns true if NO_PROXY contains getcomposer.org 1313 | * 1314 | * @param string $url http(s)://getcomposer.org 1315 | * 1316 | * @return bool 1317 | */ 1318 | public function test($url) 1319 | { 1320 | if (!$this->composerInNoProxy) { 1321 | return false; 1322 | } 1323 | 1324 | if (empty($this->rulePorts)) { 1325 | return true; 1326 | } 1327 | 1328 | if (strpos($url, 'http://') === 0) { 1329 | $port = 80; 1330 | } else { 1331 | $port = 443; 1332 | } 1333 | 1334 | return in_array($port, $this->rulePorts); 1335 | } 1336 | } 1337 | 1338 | class HttpClient { 1339 | 1340 | private $options = array('http' => array()); 1341 | private $disableTls = false; 1342 | 1343 | public function __construct($disableTls = false, $cafile = false) 1344 | { 1345 | $this->disableTls = $disableTls; 1346 | if ($this->disableTls === false) { 1347 | if (!empty($cafile) && !is_dir($cafile)) { 1348 | if (!is_readable($cafile) || !validateCaFile(file_get_contents($cafile))) { 1349 | throw new RuntimeException('The configured cafile (' .$cafile. ') was not valid or could not be read.'); 1350 | } 1351 | } 1352 | $options = $this->getTlsStreamContextDefaults($cafile); 1353 | $this->options = array_replace_recursive($this->options, $options); 1354 | } 1355 | } 1356 | 1357 | public function get($url) 1358 | { 1359 | $context = $this->getStreamContext($url); 1360 | $result = file_get_contents($url, false, $context); 1361 | 1362 | if ($result && extension_loaded('zlib')) { 1363 | $decode = false; 1364 | foreach ($http_response_header as $header) { 1365 | if (preg_match('{^content-encoding: *gzip *$}i', $header)) { 1366 | $decode = true; 1367 | continue; 1368 | } elseif (preg_match('{^HTTP/}i', $header)) { 1369 | $decode = false; 1370 | } 1371 | } 1372 | 1373 | if ($decode) { 1374 | if (version_compare(PHP_VERSION, '5.4.0', '>=')) { 1375 | $result = zlib_decode($result); 1376 | } else { 1377 | // work around issue with gzuncompress & co that do not work with all gzip checksums 1378 | $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result)); 1379 | } 1380 | 1381 | if (!$result) { 1382 | throw new RuntimeException('Failed to decode zlib stream'); 1383 | } 1384 | } 1385 | } 1386 | 1387 | return $result; 1388 | } 1389 | 1390 | protected function getStreamContext($url) 1391 | { 1392 | if ($this->disableTls === false) { 1393 | if (PHP_VERSION_ID < 50600) { 1394 | $this->options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST); 1395 | } 1396 | } 1397 | // Keeping the above mostly isolated from the code copied from Composer. 1398 | return $this->getMergedStreamContext($url); 1399 | } 1400 | 1401 | protected function getTlsStreamContextDefaults($cafile) 1402 | { 1403 | $ciphers = implode(':', array( 1404 | 'ECDHE-RSA-AES128-GCM-SHA256', 1405 | 'ECDHE-ECDSA-AES128-GCM-SHA256', 1406 | 'ECDHE-RSA-AES256-GCM-SHA384', 1407 | 'ECDHE-ECDSA-AES256-GCM-SHA384', 1408 | 'DHE-RSA-AES128-GCM-SHA256', 1409 | 'DHE-DSS-AES128-GCM-SHA256', 1410 | 'kEDH+AESGCM', 1411 | 'ECDHE-RSA-AES128-SHA256', 1412 | 'ECDHE-ECDSA-AES128-SHA256', 1413 | 'ECDHE-RSA-AES128-SHA', 1414 | 'ECDHE-ECDSA-AES128-SHA', 1415 | 'ECDHE-RSA-AES256-SHA384', 1416 | 'ECDHE-ECDSA-AES256-SHA384', 1417 | 'ECDHE-RSA-AES256-SHA', 1418 | 'ECDHE-ECDSA-AES256-SHA', 1419 | 'DHE-RSA-AES128-SHA256', 1420 | 'DHE-RSA-AES128-SHA', 1421 | 'DHE-DSS-AES128-SHA256', 1422 | 'DHE-RSA-AES256-SHA256', 1423 | 'DHE-DSS-AES256-SHA', 1424 | 'DHE-RSA-AES256-SHA', 1425 | 'AES128-GCM-SHA256', 1426 | 'AES256-GCM-SHA384', 1427 | 'AES128-SHA256', 1428 | 'AES256-SHA256', 1429 | 'AES128-SHA', 1430 | 'AES256-SHA', 1431 | 'AES', 1432 | 'CAMELLIA', 1433 | 'DES-CBC3-SHA', 1434 | '!aNULL', 1435 | '!eNULL', 1436 | '!EXPORT', 1437 | '!DES', 1438 | '!RC4', 1439 | '!MD5', 1440 | '!PSK', 1441 | '!aECDH', 1442 | '!EDH-DSS-DES-CBC3-SHA', 1443 | '!EDH-RSA-DES-CBC3-SHA', 1444 | '!KRB5-DES-CBC3-SHA', 1445 | )); 1446 | 1447 | /** 1448 | * CN_match and SNI_server_name are only known once a URL is passed. 1449 | * They will be set in the getOptionsForUrl() method which receives a URL. 1450 | * 1451 | * cafile or capath can be overridden by passing in those options to constructor. 1452 | */ 1453 | $options = array( 1454 | 'ssl' => array( 1455 | 'ciphers' => $ciphers, 1456 | 'verify_peer' => true, 1457 | 'verify_depth' => 7, 1458 | 'SNI_enabled' => true, 1459 | ) 1460 | ); 1461 | 1462 | /** 1463 | * Attempt to find a local cafile or throw an exception. 1464 | * The user may go download one if this occurs. 1465 | */ 1466 | if (!$cafile) { 1467 | $cafile = self::getSystemCaRootBundlePath(); 1468 | } 1469 | if (is_dir($cafile)) { 1470 | $options['ssl']['capath'] = $cafile; 1471 | } elseif ($cafile) { 1472 | $options['ssl']['cafile'] = $cafile; 1473 | } else { 1474 | throw new RuntimeException('A valid cafile could not be located automatically.'); 1475 | } 1476 | 1477 | /** 1478 | * Disable TLS compression to prevent CRIME attacks where supported. 1479 | */ 1480 | if (version_compare(PHP_VERSION, '5.4.13') >= 0) { 1481 | $options['ssl']['disable_compression'] = true; 1482 | } 1483 | 1484 | return $options; 1485 | } 1486 | 1487 | /** 1488 | * function copied from Composer\Util\StreamContextFactory::initOptions 1489 | * 1490 | * Any changes should be applied there as well, or backported here. 1491 | * 1492 | * @param string $url URL the context is to be used for 1493 | * @return resource Default context 1494 | * @throws \RuntimeException if https proxy required and OpenSSL uninstalled 1495 | */ 1496 | protected function getMergedStreamContext($url) 1497 | { 1498 | $options = $this->options; 1499 | 1500 | // Handle HTTP_PROXY/http_proxy on CLI only for security reasons 1501 | if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { 1502 | $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']); 1503 | } 1504 | 1505 | // Prefer CGI_HTTP_PROXY if available 1506 | if (!empty($_SERVER['CGI_HTTP_PROXY'])) { 1507 | $proxy = parse_url($_SERVER['CGI_HTTP_PROXY']); 1508 | } 1509 | 1510 | // Override with HTTPS proxy if present and URL is https 1511 | if (preg_match('{^https://}i', $url) && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) { 1512 | $proxy = parse_url(!empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY']); 1513 | } 1514 | 1515 | // Remove proxy if URL matches no_proxy directive 1516 | if (!empty($_SERVER['NO_PROXY']) || !empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) { 1517 | $pattern = new NoProxyPattern(!empty($_SERVER['no_proxy']) ? $_SERVER['no_proxy'] : $_SERVER['NO_PROXY']); 1518 | if ($pattern->test($url)) { 1519 | unset($proxy); 1520 | } 1521 | } 1522 | 1523 | if (!empty($proxy)) { 1524 | $proxyURL = isset($proxy['scheme']) ? $proxy['scheme'] . '://' : ''; 1525 | $proxyURL .= isset($proxy['host']) ? $proxy['host'] : ''; 1526 | 1527 | if (isset($proxy['port'])) { 1528 | $proxyURL .= ":" . $proxy['port']; 1529 | } elseif (strpos($proxyURL, 'http://') === 0) { 1530 | $proxyURL .= ":80"; 1531 | } elseif (strpos($proxyURL, 'https://') === 0) { 1532 | $proxyURL .= ":443"; 1533 | } 1534 | 1535 | // check for a secure proxy 1536 | if (strpos($proxyURL, 'https://') === 0) { 1537 | if (!extension_loaded('openssl')) { 1538 | throw new RuntimeException('You must enable the openssl extension to use a secure proxy.'); 1539 | } 1540 | if (strpos($url, 'https://') === 0) { 1541 | throw new RuntimeException('PHP does not support https requests through a secure proxy.'); 1542 | } 1543 | } 1544 | 1545 | // http(s):// is not supported in proxy 1546 | $proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL); 1547 | 1548 | $options['http'] = array( 1549 | 'proxy' => $proxyURL, 1550 | ); 1551 | 1552 | // add request_fulluri for http requests 1553 | if ('http' === parse_url($url, PHP_URL_SCHEME)) { 1554 | $options['http']['request_fulluri'] = true; 1555 | } 1556 | 1557 | // handle proxy auth if present 1558 | if (isset($proxy['user'])) { 1559 | $auth = rawurldecode($proxy['user']); 1560 | if (isset($proxy['pass'])) { 1561 | $auth .= ':' . rawurldecode($proxy['pass']); 1562 | } 1563 | $auth = base64_encode($auth); 1564 | 1565 | $options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n"; 1566 | } 1567 | } 1568 | 1569 | if (isset($options['http']['header'])) { 1570 | $options['http']['header'] .= "Connection: close\r\n"; 1571 | } else { 1572 | $options['http']['header'] = "Connection: close\r\n"; 1573 | } 1574 | if (extension_loaded('zlib')) { 1575 | $options['http']['header'] .= "Accept-Encoding: gzip\r\n"; 1576 | } 1577 | $options['http']['header'] .= "User-Agent: ".COMPOSER_INSTALLER."\r\n"; 1578 | $options['http']['protocol_version'] = 1.1; 1579 | $options['http']['timeout'] = 600; 1580 | 1581 | return stream_context_create($options); 1582 | } 1583 | 1584 | /** 1585 | * This method was adapted from Sslurp. 1586 | * https://github.com/EvanDotPro/Sslurp 1587 | * 1588 | * (c) Evan Coury 1589 | * 1590 | * For the full copyright and license information, please see below: 1591 | * 1592 | * Copyright (c) 2013, Evan Coury 1593 | * All rights reserved. 1594 | * 1595 | * Redistribution and use in source and binary forms, with or without modification, 1596 | * are permitted provided that the following conditions are met: 1597 | * 1598 | * * Redistributions of source code must retain the above copyright notice, 1599 | * this list of conditions and the following disclaimer. 1600 | * 1601 | * * Redistributions in binary form must reproduce the above copyright notice, 1602 | * this list of conditions and the following disclaimer in the documentation 1603 | * and/or other materials provided with the distribution. 1604 | * 1605 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 1606 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 1607 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 1608 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 1609 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 1610 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 1611 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 1612 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1613 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1614 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1615 | */ 1616 | public static function getSystemCaRootBundlePath() 1617 | { 1618 | static $caPath = null; 1619 | 1620 | if ($caPath !== null) { 1621 | return $caPath; 1622 | } 1623 | 1624 | // If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that. 1625 | // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. 1626 | $envCertFile = getenv('SSL_CERT_FILE'); 1627 | if ($envCertFile && is_readable($envCertFile) && validateCaFile(file_get_contents($envCertFile))) { 1628 | return $caPath = $envCertFile; 1629 | } 1630 | 1631 | // If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that. 1632 | // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. 1633 | $envCertDir = getenv('SSL_CERT_DIR'); 1634 | if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) { 1635 | return $caPath = $envCertDir; 1636 | } 1637 | 1638 | $configured = ini_get('openssl.cafile'); 1639 | if ($configured && strlen($configured) > 0 && is_readable($configured) && validateCaFile(file_get_contents($configured))) { 1640 | return $caPath = $configured; 1641 | } 1642 | 1643 | $configured = ini_get('openssl.capath'); 1644 | if ($configured && is_dir($configured) && is_readable($configured)) { 1645 | return $caPath = $configured; 1646 | } 1647 | 1648 | $caBundlePaths = array( 1649 | '/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package) 1650 | '/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package) 1651 | '/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package) 1652 | '/usr/local/share/certs/ca-root-nss.crt', // FreeBSD (ca_root_nss_package) 1653 | '/usr/ssl/certs/ca-bundle.crt', // Cygwin 1654 | '/opt/local/share/curl/curl-ca-bundle.crt', // OS X macports, curl-ca-bundle package 1655 | '/usr/local/share/curl/curl-ca-bundle.crt', // Default cURL CA bunde path (without --with-ca-bundle option) 1656 | '/usr/share/ssl/certs/ca-bundle.crt', // Really old RedHat? 1657 | '/etc/ssl/cert.pem', // OpenBSD 1658 | '/usr/local/etc/ssl/cert.pem', // FreeBSD 10.x 1659 | '/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package 1660 | '/usr/local/etc/openssl@1.1/cert.pem', // OS X homebrew, openssl@1.1 package 1661 | ); 1662 | 1663 | foreach ($caBundlePaths as $caBundle) { 1664 | if (@is_readable($caBundle) && validateCaFile(file_get_contents($caBundle))) { 1665 | return $caPath = $caBundle; 1666 | } 1667 | } 1668 | 1669 | foreach ($caBundlePaths as $caBundle) { 1670 | $caBundle = dirname($caBundle); 1671 | if (is_dir($caBundle) && glob($caBundle.'/*')) { 1672 | return $caPath = $caBundle; 1673 | } 1674 | } 1675 | 1676 | return $caPath = false; 1677 | } 1678 | 1679 | public static function getPackagedCaFile() 1680 | { 1681 | return <<