{"id":364747,"date":"2024-05-21T02:23:34","date_gmt":"2024-05-21T02:23:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364747"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:23:34","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364747","title":{"rendered":"<span>\u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439 \u0432 Laravel 11<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u0445\u043e\u0434 Laravel 11 <a href=\"https:\/\/laravel.com\/docs\/releases#support-policy\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u043c\u0435\u0447\u0435\u043d<\/a> \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b 2024-\u0433\u043e \u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0443\u0436\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043c\u0435\u0441\u044f\u0446\u0435.<\/p>\n<p>\u042f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u0430, \u0440\u0435\u0448\u0438\u043b \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u0440\u0443\u043f\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438. \u041f\u043e\u043c\u043d\u044e \u043a\u0430\u043a \u043f\u043e\u043b \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u0432 <a href=\"https:\/\/laravel-news.com\/laravel-11\" rel=\"noopener noreferrer nofollow\">Laravel News \u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043e \u0442\u043e\u043c, \u0447\u0442\u043e Http Kernel \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u0431\u044b\u0442\u0438\u0435, \u0438 \u043d\u0435 \u043f\u0440\u0438\u0434\u0430\u043b \u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>laravel new project --dev<\/code>, \u044f \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u0438\u0432\u043b\u0451\u043d \u0442\u0435\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0411\u044b\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u043f\u0430\u043f\u043a\u0443 <code>config<\/code> (\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>php artisan config:publish<\/code>)!<\/p>\n<p>\u0418, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0442\u0430\u043c \u043d\u0435\u0442 Http Kernel. \u0418\u0442\u0430\u043a&#8230; \u043a\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438? \u0414\u043e Laravel 11 \u044f\u0434\u0440\u043e Http Kernel, \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438 <code>app\/Http\/Kernel.php<\/code>,\u0431\u044b\u043b\u043e \u043c\u0435\u0441\u0442\u043e\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e Laravel 11 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code>, \u0435\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0412\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/lumen.laravel.com\" rel=\"noopener noreferrer nofollow\">Lumen<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u043e\u0433\u0430\u0442\u044c.<\/p>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Laravel \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 4.2, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>Kernel.php<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u044f\u0432\u043d\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439.<\/p>\n<p>\u041d\u043e\u0432\u044b\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">return Application::configure()     ->withProviders()     ->withRouting(         web: __DIR__.'\/..\/routes\/web.php',         \/\/ api: __DIR__.'\/..\/routes\/api.php',         commands: __DIR__.'\/..\/routes\/console.php',         \/\/ channels: __DIR__.'\/..\/routes\/channels.php',     )     ->withMiddleware(function (Middleware $middleware) {         \/\/     })     ->withExceptions(function (Exceptions $exceptions) {         \/\/     })->create();<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044e \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438, \u043d\u043e, \u043a\u0430\u043a \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0436\u0435\u043b\u0438 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435. \u042f \u0441\u0438\u0434\u0435\u043b \u0438 \u043b\u043e\u043c\u0430\u043b \u0433\u043e\u043b\u043e\u0432\u0443 \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438? \u041a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e? \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u044d\u0442\u043e, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b <a href=\"https:\/\/github.com\/laravel\/framework\/blob\/master\/src\/Illuminate\/Foundation\/Configuration\/Middleware.php\" rel=\"noopener noreferrer nofollow\">Illuminate\\Foundation\\Configuration\\Middleware<\/a>.<\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 <code>Application::configure()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>Illuminate\\Foundation\\Configuration\\ApplicationBuilder<\/code>, \u0433\u0434\u0435 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <code>withProviders()<\/code>, <code>withRouting()<\/code>, <code>withMiddleware()<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>withMiddleware()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (<code>callable<\/code>).<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0448\u0430\u0431\u043b\u043e\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0430\u043b\u0438\u0430\u0441\u044b \u0434\u043b\u044f \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439, \u0432\u044b\u0437\u0432\u0430\u0432 <code>alias()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     $middleware->alias([         'some_key' => \\App\\Http\\Middleware\\MyMiddleware::class,     ]); }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>some_key<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430\u043c, \u0442\u0430\u043a \u0438 \u0438\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u043c. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>append()<\/code> \u0438 <code>prepend()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439.<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     \/\/ Using a string     $middleware->append(\\App\\Http\\Middleware\\MyMiddleware::class);      \/\/ Or adding multiple     $middleware->append([         \\App\\Http\\Middleware\\MyMiddleware::class,         \\App\\Http\\Middleware\\MyOtherMiddleware::class,     ]); }<\/code><\/pre>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438, \u0432\u044b\u0437\u0432\u0430\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>remove()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     \/\/ Using a string     $middleware->remove(\\Illuminate\\Http\\Middleware\\ValidatePostSize::class);      \/\/ Or removing multiple default middleware     $middleware->remove([         \\Illuminate\\Http\\Middleware\\TrustProxies::class,         \\Illuminate\\Http\\Middleware\\HandleCors::class,     ]); }<\/code><\/pre>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>web<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>appendToGroup()<\/code>, <code>prependToGroup()<\/code> \u0438 <code>removeFromGroup()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     $middleware->appendToGroup('web', \\App\\Http\\Middleware\\MyMiddleware::class); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438\/\u043a\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u043c\u043e\u0439\u043a\u0443 (\u0430 \u044d\u0442\u043e \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442), \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0432 \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432 <a href=\"https:\/\/www.amitmerchant.com\/invokable-classes-php\/\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/a>.<\/p>\n<p>\u042f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 \u0432 <code>app\/Http<\/code> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>AppMiddleware.php<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0442\u0430\u0440\u044b\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0438 \u0443\u043c\u0438\u0440\u0430\u044e\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e <code>Kernel.php<\/code>.<\/p>\n<pre><code class=\"php\">&lt;?php  namespace App\\Http;  use Illuminate\\Foundation\\Configuration\\Middleware;  class AppMiddleware {     public function __invoke(Middleware $middleware)     {         $middleware->appendToGroup('web', \\App\\Http\\Middleware\\MyMiddleware::class);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 <code>bootstrap\/app.php<\/code> \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"php\">return Application::configure()     ->withProviders()     ->withRouting(         web: __DIR__.'\/..\/routes\/web.php',         \/\/ api: __DIR__.'\/..\/routes\/api.php',         commands: __DIR__.'\/..\/routes\/console.php',         \/\/ channels: __DIR__.'\/..\/routes\/channels.php',     )     ->withMiddleware(new \\App\\Http\\AppMiddleware()) \/\/ here     ->withExceptions(function (Exceptions $exceptions) {         \/\/     })->create();<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u0451 \u043d\u043e\u0432\u043e\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u044b \u0434\u0430\u044e\u0442\u0441\u044f \u0442\u044f\u0436\u0435\u043b\u043e. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u043c\u0435\u043d\u044f \u043c\u0443\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0432\u043e\u043f\u0440\u043e\u0441. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0451 \u0442\u0435 \u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u0440\u0430\u0445.<\/p>\n<p>\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u044f\u0432\u043d\u044b\u0445 \u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0439 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439. \u0418\u043c\u0435\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0442. \u041d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0412\u0430\u0441 \u0437\u043d\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u044f\u0445, \u043d\u043e \u0438 \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434 \u0430\u043b\u0438\u0430\u0441\u0430\u043c\u0438. \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u0440\u0438\u0432\u0443\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u0436\u0435 \u044f \u0437\u0430\u0431\u044b\u0432\u0430\u044e \u0447\u0442\u043e \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043f\u043e-\u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0438\u043b\u0438 \u043a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b, \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0444\u0430\u0439\u043b <code>app\/Http\/Kernel.php<\/code>.<\/p>\n<p>\u042f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043e\u043d\u043e \u0442\u043e\u0433\u043e. \u0410 \u0447\u0442\u043e \u0412\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785026\/\"> https:\/\/habr.com\/ru\/articles\/785026\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u044b\u0445\u043e\u0434 Laravel 11 <a href=\"https:\/\/laravel.com\/docs\/releases#support-policy\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u043c\u0435\u0447\u0435\u043d<\/a> \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b 2024-\u0433\u043e \u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0443\u0436\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043c\u0435\u0441\u044f\u0446\u0435.<\/p>\n<p>\u042f \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0430\u0442\u0430 \u0432\u044b\u0445\u043e\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u0430, \u0440\u0435\u0448\u0438\u043b \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u0440\u0443\u043f\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438. \u041f\u043e\u043c\u043d\u044e \u043a\u0430\u043a \u043f\u043e\u043b \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u0432 <a href=\"https:\/\/laravel-news.com\/laravel-11\" rel=\"noopener noreferrer nofollow\">Laravel News \u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043e \u0442\u043e\u043c, \u0447\u0442\u043e Http Kernel \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u0431\u044b\u0442\u0438\u0435, \u0438 \u043d\u0435 \u043f\u0440\u0438\u0434\u0430\u043b \u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>laravel new project --dev<\/code>, \u044f \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u0438\u0432\u043b\u0451\u043d \u0442\u0435\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0411\u044b\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u043f\u0430\u043f\u043a\u0443 <code>config<\/code> (\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>php artisan config:publish<\/code>)!<\/p>\n<p>\u0418, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0442\u0430\u043c \u043d\u0435\u0442 Http Kernel. \u0418\u0442\u0430\u043a&#8230; \u043a\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438? \u0414\u043e Laravel 11 \u044f\u0434\u0440\u043e Http Kernel, \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438 <code>app\/Http\/Kernel.php<\/code>,\u0431\u044b\u043b\u043e \u043c\u0435\u0441\u0442\u043e\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e Laravel 11 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code>, \u0435\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0412\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/lumen.laravel.com\" rel=\"noopener noreferrer nofollow\">Lumen<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u043e\u0433\u0430\u0442\u044c.<\/p>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Laravel \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 4.2, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u044b. \u0412\u043c\u0435\u0441\u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>Kernel.php<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u044f\u0432\u043d\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439.<\/p>\n<p>\u041d\u043e\u0432\u044b\u0439 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">return Application::configure()     ->withProviders()     ->withRouting(         web: __DIR__.'\/..\/routes\/web.php',         \/\/ api: __DIR__.'\/..\/routes\/api.php',         commands: __DIR__.'\/..\/routes\/console.php',         \/\/ channels: __DIR__.'\/..\/routes\/channels.php',     )     ->withMiddleware(function (Middleware $middleware) {         \/\/     })     ->withExceptions(function (Exceptions $exceptions) {         \/\/     })->create();<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044e \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438, \u043d\u043e, \u043a\u0430\u043a \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0436\u0435\u043b\u0438 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435. \u042f \u0441\u0438\u0434\u0435\u043b \u0438 \u043b\u043e\u043c\u0430\u043b \u0433\u043e\u043b\u043e\u0432\u0443 \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438? \u041a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e? \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u044d\u0442\u043e, \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b <a href=\"https:\/\/github.com\/laravel\/framework\/blob\/master\/src\/Illuminate\/Foundation\/Configuration\/Middleware.php\" rel=\"noopener noreferrer nofollow\">Illuminate\\Foundation\\Configuration\\Middleware<\/a>.<\/p>\n<p>\u0412\u044b\u0437\u043e\u0432 <code>Application::configure()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>Illuminate\\Foundation\\Configuration\\ApplicationBuilder<\/code>, \u0433\u0434\u0435 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <code>withProviders()<\/code>, <code>withRouting()<\/code>, <code>withMiddleware()<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>withMiddleware()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (<code>callable<\/code>).<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0448\u0430\u0431\u043b\u043e\u043d, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0430\u043b\u0438\u0430\u0441\u044b \u0434\u043b\u044f \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439, \u0432\u044b\u0437\u0432\u0430\u0432 <code>alias()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     $middleware->alias([         'some_key' => \\App\\Http\\Middleware\\MyMiddleware::class,     ]); }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f <code>some_key<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430\u043c, \u0442\u0430\u043a \u0438 \u0438\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u043c. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>append()<\/code> \u0438 <code>prepend()<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439.<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     \/\/ Using a string     $middleware->append(\\App\\Http\\Middleware\\MyMiddleware::class);      \/\/ Or adding multiple     $middleware->append([         \\App\\Http\\Middleware\\MyMiddleware::class,         \\App\\Http\\Middleware\\MyOtherMiddleware::class,     ]); }<\/code><\/pre>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438, \u0432\u044b\u0437\u0432\u0430\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>remove()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     \/\/ Using a string     $middleware->remove(\\Illuminate\\Http\\Middleware\\ValidatePostSize::class);      \/\/ Or removing multiple default middleware     $middleware->remove([         \\Illuminate\\Http\\Middleware\\TrustProxies::class,         \\Illuminate\\Http\\Middleware\\HandleCors::class,     ]); }<\/code><\/pre>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>web<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>appendToGroup()<\/code>, <code>prependToGroup()<\/code> \u0438 <code>removeFromGroup()<\/code>:<\/p>\n<pre><code class=\"php\">function (Middleware $middleware) {     $middleware->appendToGroup('web', \\App\\Http\\Middleware\\MyMiddleware::class); }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438\/\u043a\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b <code>bootstrap\/app.php<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043f\u043e\u043c\u043e\u0439\u043a\u0443 (\u0430 \u044d\u0442\u043e \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442), \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0432 \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432 <a href=\"https:\/\/www.amitmerchant.com\/invokable-classes-php\/\" rel=\"noopener noreferrer nofollow\">\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/a>.<\/p>\n<p>\u042f \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043b\u0430\u0441\u0441 \u0432 <code>app\/Http<\/code> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>AppMiddleware.php<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0442\u0430\u0440\u044b\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0438 \u0443\u043c\u0438\u0440\u0430\u044e\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e <code>Kernel.php<\/code>.<\/p>\n<pre><code class=\"php\">&lt;?php  namespace App\\Http;  use Illuminate\\Foundation\\Configuration\\Middleware;  class AppMiddleware {     public function __invoke(Middleware $middleware)     {         $middleware->appendToGroup('web', \\App\\Http\\Middleware\\MyMiddleware::class);     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u0444\u0430\u0439\u043b\u0435 <code>bootstrap\/app.php<\/code> \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"php\">return Application::configure()     ->withProviders()     ->withRouting(         web: __DIR__.'\/..\/routes\/web.php',         \/\/ api: __DIR__.'\/..\/routes\/api.php',         commands: __DIR__.'\/..\/routes\/console.php',         \/\/ channels: __DIR__.'\/..\/routes\/channels.php',     )     ->withMiddleware(new \\App\\Http\\AppMiddleware()) \/\/ here     ->withExceptions(function (Exceptions $exceptions) {         \/\/     })->create();<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u0451 \u043d\u043e\u0432\u043e\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u044b \u0434\u0430\u044e\u0442\u0441\u044f \u0442\u044f\u0436\u0435\u043b\u043e. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u043c\u0435\u043d\u044f \u043c\u0443\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0432\u043e\u043f\u0440\u043e\u0441. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0451 \u0442\u0435 \u0436\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0432\u0441\u0435\u043c \u044d\u0442\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u0440\u0430\u0445.<\/p>\n<p>\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u044f\u0432\u043d\u044b\u0445 \u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0439 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0435\u0439. \u0418\u043c\u0435\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0442. \u041d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0412\u0430\u0441 \u0437\u043d\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u044f\u0445, \u043d\u043e \u0438 \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434 \u0430\u043b\u0438\u0430\u0441\u0430\u043c\u0438. \u041b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u0440\u0438\u0432\u0443\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0414\u0430\u0436\u0435 \u044f \u0437\u0430\u0431\u044b\u0432\u0430\u044e \u0447\u0442\u043e \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u043f\u043e-\u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0438\u043b\u0438 \u043a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b, \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0444\u0430\u0439\u043b <code>app\/Http\/Kernel.php<\/code>.<\/p>\n<p>\u042f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043e\u043d\u043e \u0442\u043e\u0433\u043e. \u0410 \u0447\u0442\u043e \u0412\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785026\/\"> https:\/\/habr.com\/ru\/articles\/785026\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364747","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364747"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364747\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}