ุงููุงู ุจูููุง ู
ู ุฌุฏูุฏ ูู ู
ูุงูุฉ ู
ูู
ุฉ ููู ุงููู ุนุงูุฒ ูุนู
ู upgrade ู ูุงุฑููู 12 ๐คฉ
ุทุจุนุงู ูู ุงูุจุฏุงูุฉ ูุฏุง Taylor Otwell ูุถุญ ูู Laracon EU ุฅู ูุงุฑููู 12 ููุตุญููุง release ูู 24 ูุจุฑุงูุฑ, ู ูุงู ุฅูู ู
ุด ููููู ููู breaking change ุฃู ุชุบููุฑ ูุจูุฑ ู ุงู skeleton ุฒู ู
ุง ุญุตู ูู ูุงุฑููู 11. ูู
ุง ุณู
ุนุช ุงูุฎุจุฑ ุฏุง ุงุชุญู
ููุณุช ูุงู ุฏุง ููุดุฌุนูู ุงุนู
ู upgrade ููุจููุฌ ุนุดุงู ุชููู ุฌุงูุฒุฉ ูู ุงุณุชูุจุงู ุงูููุฑุฌู ุงูุฌุฏูุฏ ๐จ๐ป
ู ูุนูุงู ุนู
ูุช ุงู upgrade ุฏุง ู ูุฑุฑุช ุฃูุดุฑ ู
ูุงูุฉ ุนุดุงู ุงููู ุนูู ุงูุฎุทูุงุช ุงููู ุนู
ูุชูุง ูู ุงู upgrade ๐ค
ุฃูู ุญุงุฌุฉ ุนู
ูุชูุง ูู ุฅูู ูููุช ูู ุงูุญุงุฌุงุช ุงููู ู
ุด ูุชุชุงุซุฑ ู
ู ููุฑุฌู ููุชุงูู ุฒู ุงู Actions ู ุงู Repositories ู ุงู Contracts ู ู
ู
ูู ุชููู ุงู Requests ู ุงู Mails ู ุงู Jobs ูุงู ุงูุชุบููุฑ ูููู
ุจุณูุท ุฌุฏุงู ๐
ููุฌู ุจูุง ููุฌุฒุก ุงูุฎุงุต ุจุงู routes ู ุงู middlewares ูุงู ุฏูู ูููู
ุดุบู ูุชูุฑ, ุฏูููุชู ุชุนุงููุง ููุชุญ ุงู bootstrap/app.php ูุงู ุฏุง ุงููู ููุนุฑูู ููู ู
ูุงู ุงู routes ุจุชุงุนุชูุง
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: [
__DIR__ . '/../routes/web.php',
__DIR__ . '/../routes/dashboard.php',
],
api: __DIR__ . '/../routes/api.php'
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
ูู ุญุฐูุช ู
ูุซูุฏ ุงู withMiddleware ููุถุฑุจ ุงูุณุจุดู ู
ุนุงู.
ุฒู ู
ุง ูุงุถุญ ูู ุงูููุฏ ุฏุง, ุฅูู ู
ู
ูู ุชู
ุฑุฑ array ุจ ู
ูุงู ุงู route files ู ูู ุนูุฏู ูุงูู ูุงุญุฏ ู
ู
ูู ุชูุชุจ string ุนุงุฏู, ู ููุฐุง ุจุงููุณุจุฉ ูู API route files, ุทุจุนุงู ุฏุง ููุฎูู ุงู route file ุจุชุงุนู ุดููู ูุฏุง ู
ุซูุงู ๐
Route::middleware('auth')
->prefix('cats')
->name('cats.')
->controller(CatController::class)
->group(function () {
//
});
ุงูุทุฑููุฉ ุงููู ุฌุงูุฉ ุฏู ูู ุงููู ุงุณุชุฎุฏู
ุชูุง ู ู
ุด ูุชุชุนุจู ูุงูู ูุชููู ุงูููุฏ ุงููู ูู ุงู RouteServiceProvider ู ุงู route file ู
ุด ููููู ุฒู ุงููู ูุงุช
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
api: __DIR__ . '/../routes/api.php',
then: function () {
Route::middleware(['web', 'throttle:preventDDOS'])
->prefix('admin')
->name('admin.')
->group(base_path('routes/dashboard.php'));
Route::middleware(['web', 'throttle:preventDDOS'])
->name('blog.')
->group(base_path('routes/web.php'));
}
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
ูู ุงูุดูู ุฏุง ู
ุฑุฑูุง closure ูู then argument, ู ูุชูุงุญุธ ุฅูู ู
ุณุชุญุฏู
throttle ู ุนุดุงู ุชุนู
ู register ูู throttle ูู ุงูููุฑุฌู ุงูุฌุฏูุฏ ูุชุฑูุญ ูู AppServiceProvider ู ุชูุชุจ ุงูููุฏ ุฏุง
use Illuminate\Http\Request;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
RateLimiter::for('preventDDOS', function (Request $request) {
return auth()->check() ?
Limit::none() : Limit::perMinute(60)->by($request->ip());
});
}
}
ุฏู ู
ูุงูุฉ ุงุชููู
ุช ูููุง ุนู ุงู RateLimiter ุจุฅุณุชูุงุถุฉ.
ู ุจูุฏุง ุงููู ุฎูุตุช ูู ุญุงุฌุฉ ุชุฎุต ุงู routes. ุชุนุงููุง ุจูุง ูุดูู ุงู middlewares ูููุงูู ุฅู ู
ุด ู
ูุฌูุฏ ุงู middleware, ุฒู ู
ุซูุงู ุงููู ุจูุนู
ู redirect ููููุฒุฑ ูู ูุงู auth ุฃู guest ู ุฏุง ูุงู ุชู
ุฅุณุชุจุฏุงููู
ุจู
ูุซูุฏุฒ...ุงููุงุง ุฒู ู
ุง ูุฑุฃุช ูุฏุง, ุชู
ุฅุณุชุจุฏุงููู
ูููู
ุจ ู
ูุซูุฏุฒ! ๐คฏ
ุชุนุงููุง ูุดูู ุจุนุถ ุงูู
ูุซูุฏุฒ ุฏู ู ุฅุฒุงู ููุณุชุฎุฏู
ูุง
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
...
)
->withMiddleware(function (Middleware $middleware) {
$middleware
->redirectGuestsTo('/admin/login')
->redirectUsersTo('/admin');
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
ู
ูุซูุฏ redirectGuestsTo ูู ุชุนุชุจุฑ ุจุฏูู ูู Authenticate middleware ู ู
ูุซูุฏ redirectUsersTo ูู ุชุนุชุจุฑ ุจุฏูู ูู RedirectIfAuthenticate middleware ู ุฒู ู
ุง ุงูุช ุดุงูู ุจุชู
ุฑุฑ ุงูู
ุณุงุฑ ุงููู ุนุงูุฒู ุฃู ู
ู
ูู ุชู
ุฑุฑ closure ูู
ุงู ๐
ูุชูุงูู ููุง ุทุฑู ุงุณุชุฎุฏุงู
ุงู methods ุฏู.
ุฃู
ุง ุนู ุฌุฒุก ุงูุฅูุณุจุดูุฒ, ูู ุฅูุช ุนุงูุฒ ุชุนู
ู overwrite ุนูู ุงูุฅูุณุจุดูุฒ ุงูุฎุงุตุฉ ุจ ูุงุฑููู ุฒู ุงู NOT FOUND ุฅูุณุจุดู, ูุชูุชุจ ุงูููุฏ ุงููู ุฌุงู ุฏุง
use Illuminate\Foundation\Application;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
...
)
->withMiddleware(function (Middleware $middleware) {
...
})
->withExceptions(function (Exceptions $exceptions) {
$exceptions->respond(function (Response $response) {
return CustomExceptionClass::render($response);
});
})->create();
ุทุจุนุงู ุงู render ู
ูุซูุฏ ุงูู
ูุฑูุถ ูุชุฑุฌุน ุงู custom view ุจุชุงุนู ุฒู ูุฏุง ๐โ๏ธ
namespace App\Exceptions;
class CustomExceptionClass
{
/*
* Render the exception into an HTTP response.
*/
public static function render($response)
{
$statusCode = $response->getStatusCode();
if (($statusCode >= 200 && $statusCode < 400) || request()->ajax()) {
return $response;
}
$message = array_key_exists($statusCode, $response::$statusTexts) ?
$response::$statusTexts[$statusCode] : $statusCode;
return response()->view('your-custom-view', [
'statusCode' => $statusCode,
'message' => $message,
], $statusCode);
}
}
ุญุงุจุจ ุงูุถุญูู ุฅู ูุงุฑููู ู
ุด ูุชุฑูุญ ููููุงุณ ุฏุง ูู ุญุงูุฉ ุงูุฅูุณุจุดูุฒ ุจุณ, ูุชุฑูุญ ูู ุญุงูุฉ ุงู redirect request ูู
ุงู (ู
ุซูุงู) ุนุดุงู ูุฏุง ุถูุช ุงููููุฏุดู ุงููู ูู ุงูุงูู ุฏุง.
ุฏุง ู
ุซุงู ู
ู ูุงุฑููู ุจููุถุญ ุฅุฒุงู ุชุนู
ู ูุฏุง ุจุดูู ู
ููุตู ุงูุชุฑ.
ูุฏุง ุชููู ุนู
ูุช upgrade ุจุดูู ุตุญูุญ ุงู ุดุงุก ุงููู ู ู
ุณุชุนุฏ ูุฅุณุชูุจุงู ูุงุฑููู 12 โ
ู ุฏูููุชู ุฌู ููุช ุงูุฌู
ูุฉ ุงูุดููุฑุฉ ุจุชุงุนุชูุง...ู ุจูุฏุง ุฃููู ุฎูุตุช ู ุฃุชู
ูู ุชููู ุฅุณุชูุฏุช โ