laravel framework updated to ^11.0

This commit is contained in:
erishBRBS 2025-04-03 14:50:50 +08:00
parent faee2c79aa
commit 71345b605e
33 changed files with 5291 additions and 2931 deletions

8
.env
View File

@ -1,4 +1,4 @@
\APP_NAME=Unioil
APP_NAME=Unioil
APP_ENV=local
APP_KEY=base64:0gU9IIArwNb9IW4nkiuN72zGhw0YrtIVZnM7WJxxD88=
APP_DEBUG=true
@ -7,11 +7,11 @@ APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST="172.31.28.52"
DB_HOST=db_mysql
DB_PORT=3306
DB_DATABASE="unioilLoyaltyApp"
DB_USERNAME="bindapp"
DB_PASSWORD="hive1234"
DB_USERNAME="admin_erish"
DB_PASSWORD="laravel"
BROADCAST_DRIVER=log
CACHE_DRIVER=file

View File

@ -3,6 +3,7 @@
namespace App\Exceptions;
use Exception;
use Throwable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
@ -32,7 +33,7 @@ class Handler extends ExceptionHandler
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
public function report(Throwable $exception)
{
parent::report($exception);
}
@ -44,7 +45,7 @@ class Handler extends ExceptionHandler
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}

View File

@ -19,7 +19,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Barryvdh\Cors\HandleCors::class,
// \Barryvdh\Cors\HandleCors::class,
];
/**
@ -41,7 +41,7 @@ class Kernel extends HttpKernel
'api' => [
'throttle:60,1',
'bindings',
\Barryvdh\Cors\HandleCors::class,
// \Barryvdh\Cors\HandleCors::class,
\App\Http\Middleware\BeforeMiddleware::class,
],
];

View File

@ -2,22 +2,26 @@
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
protected $proxies = '*';
/**
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers = Request::HEADER_X_FORWARDED_FOR
| Request::HEADER_X_FORWARDED_HOST
| Request::HEADER_X_FORWARDED_PORT
| Request::HEADER_X_FORWARDED_PROTO
| Request::HEADER_X_FORWARDED_AWS_ELB;
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Http\Requests;
namespace App\Http\Resources;
use Response;
use Illuminate\Http\Request;

View File

@ -28,7 +28,7 @@ class AppServiceProvider extends ServiceProvider
{
Schema::defaultStringLength(128);
$this->registerPolicies();
Passport::routes();
// Passport::routes();
}
/**

View File

@ -27,7 +27,7 @@ class AuthServiceProvider extends ServiceProvider
{
$this->registerPolicies();
Passport::routes();
// Passport::routes();
Passport::tokensExpireIn(Carbon::now()->addMonths(10));

0
bootstrap/app.php Normal file → Executable file
View File

0
bootstrap/cache/.gitignore vendored Normal file → Executable file
View File

View File

@ -5,25 +5,29 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"barryvdh/laravel-cors": "^0.11.2",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.7.*",
"laravel/passport": "^7.0",
"laravel/tinker": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"php": "^8.3.6",
"brick/math": "0.10.2",
"guzzlehttp/guzzle": "^7.0",
"laravel/framework": "^11.0",
"laravel/passport": "*",
"laravel/tinker": "^2.0",
"league/flysystem-aws-s3-v3": "^3.0",
"maatwebsite/excel": "^3.1",
"moontoast/math": "^1.1",
"ramsey/uuid": "^3.8"
"ramsey/uuid": "^4.2",
"symfony/console": "^7.0",
"symfony/error-handler": "^7.0",
"symfony/http-foundation": "^7.0",
"symfony/http-kernel": "^7.0",
"symfony/routing": "^7.0",
"symfony/validator": "^7.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"beyondcode/laravel-dump-server": "^2.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"fakerphp/faker": "^1.9",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
"nunomaduro/collision": "^8.0",
"phpunit/phpunit": "^10.0"
},
"autoload": {
"classmap": [
@ -39,12 +43,6 @@
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
@ -60,7 +58,10 @@
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
"optimize-autoloader": true,
"allow-plugins": {
"kylekatarnls/update-helper": true
}
},
"minimum-stability": "dev",
"prefer-stable": true

7943
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -172,7 +172,7 @@ return [
App\Providers\CustomPassportServiceProvider::class,
Laravel\Passport\PassportServiceProvider::class,
Barryvdh\Cors\ServiceProvider::class,
// Barryvdh\Cors\ServiceProvider::class,
],

View File

@ -1,5 +1,7 @@
<?php
use Illuminate\Support\Str;
return [
/*
@ -88,7 +90,7 @@ return [
'prefix' => env(
'CACHE_PREFIX',
str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'
),
];

View File

@ -11,13 +11,20 @@ return [
| to accept any value.
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedOriginsPatterns' => [],
'allowedHeaders' => ['*'],
'allowedMethods' => ['*'],
'exposedHeaders' => ['Content-Disposition'],
'maxAge' => 0,
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];
];

View File

@ -1,5 +1,7 @@
<?php
use Illuminate\Support\Str;
return [
/*
@ -124,7 +126,7 @@ return [
'cookie' => env(
'SESSION_COOKIE',
str_slug(env('APP_NAME', 'laravel'), '_').'_session'
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*

67
docker-compose.yml Normal file
View File

@ -0,0 +1,67 @@
services:
app:
build:
context: .
dockerfile: ./docker/php/Dockerfile
container_name: laravel-app
restart: unless-stopped
volumes:
- .:/var/www/html
- ./storage:/var/www/html/storage
- ./bootstrap/cache:/var/www/html/bootstrap/cache
depends_on:
db_mysql:
condition: service_healthy
command:
[ "sh", "-c", "/var/www/html/docker/php/entrypoint.sh" ]
healthcheck:
test: ["CMD", "pgrep", "php-fpm"]
interval: 30s
timeout: 10s
retries: 5
networks:
- app_network
db_mysql:
image: mysql:8.2
container_name: db_mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: laravel
MYSQL_DATABASE: unioilLoyaltyApp
MYSQL_USER: admin_erish
MYSQL_PASSWORD: laravel
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 30s
timeout: 10s
retries: 5
networks:
- app_network
nginx:
image: nginx:alpine
container_name: nginx
restart: unless-stopped
ports:
- "80:80"
volumes:
- .:/var/www/html
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
app:
condition: service_healthy
networks:
- app_network
volumes:
mysql-data:
storage-volume:
driver: local
networks:
app_network:
driver: bridge

25
docker/nginx/default.conf Normal file
View File

@ -0,0 +1,25 @@
server {
listen 80;
server_name localhost;
root /var/www/html/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000; # laravel app container
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}

33
docker/php/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
# Base image
FROM php:8.3-fpm-alpine
# Install required dependencies for PHP extensions and GD
RUN apk update && apk add --no-cache \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libzip-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd zip \
&& docker-php-ext-install pdo_mysql
# Install Composer
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Copy app files
COPY . /var/www/html
# Ensure entrypoint script is executable
RUN chmod +x /var/www/html/docker/php/entrypoint.sh
# Set permissions for app files
RUN chown -R www-data:www-data /var/www/html
# Expose PHP-FPM port
EXPOSE 9000
# Start PHP-FPM (Handled in entrypoint.sh)
CMD ["sh", "-c", "/var/www/html/docker/php/entrypoint.sh"]

24
docker/php/entrypoint.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
# Exit script on any error
set -e
# To Ensure we're in the right directory
cd /var/www/html
# Install dependencies
echo "Installing Composer dependencies..."
composer install --no-dev --optimize-autoloader
# Set correct permissions for storage and cache
echo "Setting correct permissions for storage and cache..."
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/
# Run migrations
echo "Running migrations..."
php artisan migrate --force
# Start PHP-FPM
echo "Starting PHP-FPM..."
php-fpm

View File

@ -1,6 +1,7 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------

View File

@ -1,5 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
@ -11,11 +13,11 @@
|
*/
// Route::get('/', function () {
// return view('welcome');
// });
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Auth::routes();
// Auth::routes();
// Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');

0
storage/.DS_Store vendored Normal file → Executable file
View File

0
storage/app/.gitignore vendored Normal file → Executable file
View File

0
storage/app/public/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/.DS_Store vendored Normal file → Executable file
View File

0
storage/framework/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/cache/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/sessions/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/testing/.gitignore vendored Normal file → Executable file
View File

0
storage/framework/views/.gitignore vendored Normal file → Executable file
View File

0
storage/logs/.gitignore vendored Normal file → Executable file
View File

0
storage/oauth-private.key Normal file → Executable file
View File

0
storage/oauth-public.key Normal file → Executable file
View File