I'm doing the same thing, the only way to make portable apps. As a tip, if you don't want a dependency like laravel-modules you can create your own composer.json in your folder structure that contains the whole app and add it to laravel's composer with a symlink path
Here's an example of a personal package composer.json
{
"name": "extend/utility",
"version": "1.0.0.1",
"description": "Utility package Laravel",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Albert",
"email": ""
}
],
"autoload": {
"psr-4": {
"Extend\Utility\": "/"
}
},
"extra": {
"laravel": {
"providers": [
"Extend\Utility\Foundation\ServiceProvider"
],
"aliases": {}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
and the laravel composer entries
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"extend/utility": "1.0.*",
"ext-pdo": "*"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"repositories": [
{
"type": "path",
"url": "./Extend/Utility/"
}
]
}
update composer and you're good to go ;)
edit: forgot to mention you need to hook into Laravel I'm using my own service provider that registers all I need so only have to add this to Laravel's via auto discover
One example:
<?php namespace Extend\Localization\Foundation;
use Extend\Localization\Service\Console\ImportCities;
use Extend\Localization\Service\Console\ImportCitiesPostalCodes;
use Extend\Localization\Service\Console\ImportCounties;
use Extend\Localization\Service\Console\ImportCountries;
use Extend\Localization\Service\Console\ImportPostalCodes;
use Extend\Localization\Service\Console\ImportStates;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
class ServiceProvider extends BaseServiceProvider
{
protected $commands =
[
ImportCountries::class,
ImportStates::class,
ImportCounties::class,
ImportCities::class,
ImportPostalCodes::class,
ImportCitiesPostalCodes::class,
];
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'localization');
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
//$this->loadTranslationsFrom(__DIR__.'/../translations', 'localization');
}
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config.php', 'localization');
$this->commands($this->commands);
// $this->app->register(RouteServiceProvider::class);
}
}