So after playing arround with laravel 5 and creating a package for it and keep updating the application. Taylor finaly pushed the keys I needed to load views and assets from my package into the Application like how you would want to do it.

Registering your views.

In your serviceprovider in the boot function you can use the following function to load them into the application loadViewsFrom($namespace, $path)
First lets take a look at the function

* Register a view file namespace.
* @param  string  $namespace
* @param  string  $path
* @return void
protected function loadViewsFrom($namespace, $path)  
    if (is_dir($appPath = $this->app->basePath().'/resources/views/vendor/'.$namespace))
        $this->app['view']->addNamespace($namespace, $appPath);

    $this->app['view']->addNamespace($namespace, $path);

Awesome so you will end up in your own service provider with something like:

$this->loadViewsFrom('acme', __DIR__ . 'resources/views');

now in the rest of your application you van call the blade templates just as it was in Laravel4: view('acme::auth.login')

Publishing assets

Taylor went all out on this one. In Laravel 4 you needed to publish the assets with namespacing like artisan assets:publish acme/foo. However now Taylor tweaked the hell out of the publish function he introduced the $publishes static var that can be used to publish any directory to another one. and do it all with a simple artisan vendor:publish.

So lets see how this works, first let us publish some images

    __DIR__ . 'public/images' => public_path('/awesomeimages')

what this will do is copy the images from vendor/acme/foo/public/images to your applications public folder public/awesomeimages. AWESOME!

Loading translations

This one is very similar to the loading views one
$this->loadTranslationsFrom('acme', 'resources/lang');

and you can call it by checking out trans('').

Awesomenes! all good luck making packages!!!

© 2015. All Rights Reserve John in 't Hout.