├── .editorconfig ├── .gitignore ├── LICENSE.md ├── README.md ├── composer.json ├── composer.lock ├── config └── example.php ├── resources └── views │ └── example.blade.php └── src ├── Console └── ExampleCommand.php ├── Example.php ├── Facades └── Example.php └── Providers └── ExampleServiceProvider.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.php] 15 | indent_size = 4 16 | 17 | [*.blade.php] 18 | indent_size = 2 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) Roots Software LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Acorn Example Package 2 | 3 | This repo can be used to scaffold an Acorn package. See the [Acorn Package Development](https://roots.io/acorn/docs/package-development/) docs for further information. 4 | 5 | ## Installation 6 | 7 | You can install this package with Composer: 8 | 9 | ```bash 10 | composer require vendor-name/example-package 11 | ``` 12 | 13 | You can publish the config file with: 14 | 15 | ```shell 16 | $ wp acorn vendor:publish --provider="VendorName\ExamplePackage\Providers\ExampleServiceProvider" 17 | ``` 18 | 19 | ## Usage 20 | 21 | From a Blade template: 22 | 23 | ```blade 24 | @include('Example::example') 25 | ``` 26 | 27 | From WP-CLI: 28 | 29 | ```shell 30 | $ wp acorn example 31 | ``` 32 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vendor-name/example-package", 3 | "type": "package", 4 | "description": "An example package for Roots Acorn.", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Brandon Nifong", 9 | "email": "brandon@tendency.me" 10 | } 11 | ], 12 | "autoload": { 13 | "psr-4": { 14 | "VendorName\\ExamplePackage\\": "src/" 15 | } 16 | }, 17 | "require": { 18 | "php": "^8.2" 19 | }, 20 | "extra": { 21 | "acorn": { 22 | "providers": [ 23 | "VendorName\\ExamplePackage\\Providers\\ExampleServiceProvider" 24 | ], 25 | "aliases": { 26 | "Example": "VendorName\\ExamplePackage\\Facades\\Example" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "8d95a37044872563be95de25668b9509", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": { 16 | "php": "^8.0" 17 | }, 18 | "platform-dev": [], 19 | "plugin-api-version": "2.3.0" 20 | } 21 | -------------------------------------------------------------------------------- /config/example.php: -------------------------------------------------------------------------------- 1 | [ 21 | 'For every Sage there is an Acorn.', 22 | ], 23 | ]; 24 | -------------------------------------------------------------------------------- /resources/views/example.blade.php: -------------------------------------------------------------------------------- 1 | {{ Example::getQuote() }} 2 | -------------------------------------------------------------------------------- /src/Console/ExampleCommand.php: -------------------------------------------------------------------------------- 1 | info( 32 | Example::getQuote() 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Example.php: -------------------------------------------------------------------------------- 1 | app = $app; 26 | } 27 | 28 | /** 29 | * Retrieve a random inspirational quote. 30 | * 31 | * @return string 32 | */ 33 | public function getQuote() 34 | { 35 | return Arr::random( 36 | config('example.quotes') 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Facades/Example.php: -------------------------------------------------------------------------------- 1 | app->singleton('Example', function () { 19 | return new Example($this->app); 20 | }); 21 | 22 | $this->mergeConfigFrom( 23 | __DIR__.'/../../config/example.php', 24 | 'example' 25 | ); 26 | } 27 | 28 | /** 29 | * Bootstrap any application services. 30 | * 31 | * @return void 32 | */ 33 | public function boot() 34 | { 35 | $this->publishes([ 36 | __DIR__.'/../../config/example.php' => $this->app->configPath('example.php'), 37 | ], 'config'); 38 | 39 | $this->loadViewsFrom( 40 | __DIR__.'/../../resources/views', 41 | 'Example', 42 | ); 43 | 44 | $this->commands([ 45 | ExampleCommand::class, 46 | ]); 47 | 48 | $this->app->make('Example'); 49 | } 50 | } 51 | --------------------------------------------------------------------------------