├── lang └── .gitkeep ├── src ├── .gitkeep └── ServiceProvider.php ├── config ├── .gitkeep └── packagename.php ├── views └── .gitkeep ├── migrations └── .gitkeep ├── .gitignore ├── routes.php ├── composer.json ├── LICENSE └── README.md /lang/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /views/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.idea/ 3 | /vendor/ 4 | composer.phar 5 | 6 | -------------------------------------------------------------------------------- /routes.php: -------------------------------------------------------------------------------- 1 | =5.4.0", 15 | "illuminate/config": "~5.0", 16 | "illuminate/support": "~5.0" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit": "~4.0" 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "Vendor\\Package\\": "src/" 24 | } 25 | }, 26 | "minimum-stability": "dev" 27 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Colin Viebrock 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /src/ServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleConfigs(); 22 | // $this->handleMigrations(); 23 | // $this->handleViews(); 24 | // $this->handleTranslations(); 25 | // $this->handleRoutes(); 26 | } 27 | 28 | /** 29 | * Register the service provider. 30 | * 31 | * @return void 32 | */ 33 | public function register() { 34 | 35 | // Bind any implementations. 36 | 37 | } 38 | 39 | /** 40 | * Get the services provided by the provider. 41 | * 42 | * @return array 43 | */ 44 | public function provides() { 45 | 46 | return []; 47 | } 48 | 49 | private function handleConfigs() { 50 | 51 | $configPath = __DIR__ . '/../config/packagename.php'; 52 | 53 | $this->publishes([$configPath => config_path('packagename.php')]); 54 | 55 | $this->mergeConfigFrom($configPath, 'packagename'); 56 | } 57 | 58 | private function handleTranslations() { 59 | 60 | $this->loadTranslationsFrom(__DIR__.'/../lang', 'packagename'); 61 | } 62 | 63 | private function handleViews() { 64 | 65 | $this->loadViewsFrom(__DIR__.'/../views', 'packagename'); 66 | 67 | $this->publishes([__DIR__.'/../views' => base_path('resources/views/vendor/packagename')]); 68 | } 69 | 70 | private function handleMigrations() { 71 | 72 | $this->publishes([__DIR__ . '/../migrations' => base_path('database/migrations')]); 73 | } 74 | 75 | private function handleRoutes() { 76 | 77 | include __DIR__.'/../routes.php'; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boilerplate Laravel 5 Package 2 | 3 | ## Installation 4 | 5 | Clone this repo with minimal history: 6 | 7 | ```sh 8 | git clone --depth 1 git@github.com:cviebrock/laravel5-package-template.git 9 | ``` 10 | 11 | Rename the directory and re-init it as your own package: 12 | 13 | ```sh 14 | mv laravel5-package-template my-package 15 | cd my-package 16 | rm -rf .git 17 | git init 18 | ``` 19 | 20 | 21 | ## Configuration 22 | 23 | The boilerplate files provide a scaffold for building your own package. You'll need to make a bunch of changes to the files we've provided to make it your own. 24 | 25 | 26 | ### composer.json 27 | 28 | Edit `composer.json` to reflect your package information. At a minimum, you will need to change the package name and autoload lines so that "vendor/package" reflects your new package's name and namespace. 29 | 30 | ```json 31 | { 32 | "name": "vendor/package", 33 | ... 34 | "autoload": { 35 | "psr-4": { 36 | "Vendor\\Package\\": "src/" 37 | } 38 | }, 39 | ... 40 | }, 41 | ``` 42 | 43 | 44 | ### config/packagename.php 45 | 46 | Rename `config/packagename.php` to something more useful, like `config/my-package.php`. This is the configuration file that Laravel will publish into it's `config` directory. Laravel 5 doesn't use the `config/packages/vendor/...` structure that Laravel 4 did, so pick a file name that's not likely to conflict with existing configuration files. 47 | 48 | 49 | ### src/ServiceProvider.php 50 | 51 | Open up `src/ServiceProvider.php` as well. At a minimum you'll need to change the namespace at the top of the file (it needs to match the PSR-4 namespace you set in `composer.json`). 52 | 53 | In the `boot()` method, comment out or uncomment the components your package will need. For example, if your package only has a configuration, then you can comment out everything except the `handleConfigs()` call: 54 | 55 | ```php 56 | public function boot() { 57 | $this->handleConfigs(); 58 | // $this->handleMigrations(); 59 | // $this->handleViews(); 60 | // $this->handleTranslations(); 61 | // $this->handleRoutes(); 62 | } 63 | ``` 64 | 65 | In the `handleConfigs()` method, you'll want to change the "packagename" references to the name you chose up above (in the [config/packagename.php] instructions). 66 | 67 | For the other methods, again change instances of "vendor" and "packagename" to your package's name. 68 | 69 | 70 | ### Last Steps 71 | 72 | Update the `LICENSE` file as required (make sure it matches what you said your package's license is in `composer.json`). 73 | 74 | Finally, edit this `README.md` file and replace it with a description of your own, awesome Laravel 5 package. 75 | 76 | Commit everything to your (newly initialized) git repo, and push it wherever you'll keep your package (Github, etc.). 77 | 78 | Enjoy coding! 79 | --------------------------------------------------------------------------------