php - Laravel 5 localization: exclude /public/ directory -


i trying implement localization in laravel 5 project , i'm running issue. middleware put in catch language follows:

<?php namespace app\http\middleware;  use closure; use illuminate\routing\redirector; use illuminate\http\request; use illuminate\foundation\application; use illuminate\contracts\routing\middleware;  class language implements middleware {      public function __construct(application $app, redirector $redirector, request $request) {         $this->app = $app;         $this->redirector = $redirector;         $this->request = $request;     }      /**      * handle incoming request.      *      * @param  \illuminate\http\request  $request      * @param  \closure  $next      * @return mixed      */     public function handle($request, closure $next)     {         // make sure current locale exists.         $locale = $request->segment(1);           if ( ! array_key_exists($locale, $this->app->config->get('app.locales'))) {             $segments = $request->segments();             $segments[0] = $this->app->config->get('app.fallback_locale');              return $this->redirector->to(implode('/', $segments));         }          $this->app->setlocale($locale);          return $next($request);     }  } 

kernel.php:

protected $middleware = [         'app\http\middleware\language',         'illuminate\foundation\http\middleware\checkformaintenancemode',         'illuminate\cookie\middleware\encryptcookies',         'illuminate\cookie\middleware\addqueuedcookiestoresponse',         'illuminate\session\middleware\startsession',         'illuminate\view\middleware\shareerrorsfromsession',         'app\http\middleware\verifycsrftoken',     ]; 

routeserviceprovider.php:

public function map(router $router, request $request)     {         $locale = $request->segment(1);          $this->app->setlocale($locale);          $router->group(['namespace' => $this->namespace, 'prefix' => $locale], function($router) {             require app_path('http/routes.php');         });     } 

it's working perfectly, except 1 thing. when try go http://0.0.0.0/public/css/images/myimage.png replacing public en , if go /en/public it's telling me route doesn't exist.

any getting public directory excluded or implementing localization in better way doesn't involve middleware?

your image must under public folder, , public folder must folder public , configured in apache.

you have fix configuration can access image using following url: http://0.0.0.0/css/images/myimage.png

and happen when public configured public folder.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -