Laravel Blog Package
Par Eric Antoine ScuccimarraI finished working on my Laravel package, which is the blog I use here (and also on my other site). I had this on my GitHub as a Laravel skeleton application, but after a few days of research and coding I now have it as a Laravel package, which can be installed via Composer. I did find a more comprehensive tutorial on writing Laravel packages, but I only just found this today after I had finished my package, so haven't really read through it.
The reason I started working on this package is because I have multiple sites that use the same code and I wanted to consolidate them so I wouldn't have to maintain two separate code bases, but the package is only in English and some of my sites are in French, so I guess my next step is adding translation to the package.
The package is on Packagist and can be installed with composer.
composer require escuccim/larablog
A few things that I struggled with and eventually figured out since my last post on this topic:
- How to publish files from the package to the containing application. I did this for both my views and the config.php file.
$this->publishes([
__DIR__.'/config/config.php' => config_path('blog.php'),
__DIR__ . '/resources/views' => base_path('resources/views/vendor/escuccim')
]);
- To default to the package config if it has not been published use:
$this->mergeConfigFrom(__DIR__.'/config/config.php', 'blog'); where 'blog' is the key for the config array.
- How to load database migrations:
$this->loadMigrationsFrom(__DIR__.'/database/migrations');
- I also updated the code so that things like caching could be turned on and off from the config.
There is still work to be done, but I just marked my GitHub repo with a stable release version, so that's something.