From ed8a80c0522b90dd514cb1c3470ba4dfb17fabb7 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Wed, 29 Dec 2021 15:42:29 -0600 Subject: [PATCH] Switch to zero-config setup, remove `config` and `bootstrap` dirs (#2839) * Remove config directory * feat(zeroconfig): Add support for zero-config * test(php-lint): remove config directory * chore(readme): update dir structure * admin/customizer has been removed Co-authored-by: QWp6t --- README.md | 11 -- bootstrap/app.php | 50 ------ bootstrap/cache/.gitignore | 2 - composer.json | 9 +- config/app.php | 202 ------------------------ config/assets.php | 41 ----- config/filesystems.php | 66 -------- config/logging.php | 106 ------------- config/view.php | 81 ---------- functions.php | 47 +++++- storage/framework/cache/.gitignore | 3 - storage/framework/cache/data/.gitignore | 2 - storage/logs/.gitignore | 2 - 13 files changed, 50 insertions(+), 572 deletions(-) delete mode 100644 bootstrap/app.php delete mode 100644 bootstrap/cache/.gitignore delete mode 100644 config/app.php delete mode 100644 config/assets.php delete mode 100644 config/filesystems.php delete mode 100644 config/logging.php delete mode 100755 config/view.php delete mode 100644 storage/framework/cache/.gitignore delete mode 100644 storage/framework/cache/data/.gitignore delete mode 100644 storage/logs/.gitignore diff --git a/README.md b/README.md index b069f0f..e41f123 100644 --- a/README.md +++ b/README.md @@ -91,21 +91,10 @@ themes/your-theme-name/ # → Root of your Sage based theme ├── app/ # → Theme PHP │ ├── Providers/ # → Service providers │ ├── View/ # → View models -│ ├── admin.php # → Theme customizer setup │ ├── filters.php # → Theme filters │ ├── helpers.php # → Helper functions │ └── setup.php # → Theme setup -├── bootstrap/ # → Acorn bootstrap -│ ├── cache/ # → Acorn cache location (never edit) -│ └── app.php # → Acorn application bootloader -├── config/ # → Config files -│ ├── app.php # → Application configuration -│ ├── assets.php # → Asset configuration -│ ├── filesystems.php # → Filesystems configuration -│ ├── logging.php # → Logging configuration -│ └── view.php # → View configuration ├── composer.json # → Autoloading for `app/` files -├── composer.lock # → Composer lock file (never edit) ├── public/ # → Built theme assets (never edit) ├── functions.php # → Theme bootloader ├── index.php # → Theme template wrapper diff --git a/bootstrap/app.php b/bootstrap/app.php deleted file mode 100644 index eddc827..0000000 --- a/bootstrap/app.php +++ /dev/null @@ -1,50 +0,0 @@ -each(function ($file) { - if (! locate_template($file = "app/{$file}.php", true, true)) { - wp_die( - /* translators: %s is replaced with the relative file path */ - sprintf(__('Error locating %s for inclusion.', 'sage'), $file) - ); - } - }); - -/* -|-------------------------------------------------------------------------- -| Enable Sage Theme Support -|-------------------------------------------------------------------------- -| -| Once our theme files are registered and available for use, we are almost -| ready to boot our application. But first, we need to signal to Acorn -| that we will need to initialize the necessary service providers built in -| for Sage when booting. -| -*/ - -add_theme_support('sage'); diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/bootstrap/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/composer.json b/composer.json index e616851..1431f71 100644 --- a/composer.json +++ b/composer.json @@ -59,10 +59,17 @@ "prefer-stable": true, "scripts": { "lint": [ - "phpcs --extensions=php --standard=PSR12 app config" + "phpcs --extensions=php --standard=PSR12 app" ], "post-autoload-dump": [ "Roots\\Acorn\\ComposerScripts::postAutoloadDump" ] + }, + "extra": { + "acorn": { + "providers": [ + "App\\Providers\\ThemeServiceProvider" + ] + } } } diff --git a/config/app.php b/config/app.php deleted file mode 100644 index d831697..0000000 --- a/config/app.php +++ /dev/null @@ -1,202 +0,0 @@ - env('APP_NAME', wp_get_theme()->get('Name')), - - /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | - */ - - 'env' => defined('WP_ENV') ? WP_ENV : env('WP_ENV', 'production'), - - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ - - 'debug' => WP_DEBUG && WP_DEBUG_DISPLAY, - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ - - 'timezone' => get_option('timezone_string', 'UTC'), - - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ - - 'locale' => get_locale(), - - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ - - 'fallback_locale' => 'en', - - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ - - 'key' => env('APP_KEY'), - - 'cipher' => 'AES-256-CBC', - - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ - - 'providers' => [ - - /* - * Laravel Framework Service Providers... - */ - // Illuminate\Auth\AuthServiceProvider::class, - // Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - // Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - // Illuminate\Cookie\CookieServiceProvider::class, - // Illuminate\Database\DatabaseServiceProvider::class, - // Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - // Illuminate\Foundation\Providers\FoundationServiceProvider::class, - // Illuminate\Hashing\HashServiceProvider::class, - // Illuminate\Mail\MailServiceProvider::class, - // Illuminate\Notifications\NotificationServiceProvider::class, - // Illuminate\Pagination\PaginationServiceProvider::class, - // Illuminate\Pipeline\PipelineServiceProvider::class, - // Illuminate\Queue\QueueServiceProvider::class, - // Illuminate\Redis\RedisServiceProvider::class, - // Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - // Illuminate\Session\SessionServiceProvider::class, - // Illuminate\Translation\TranslationServiceProvider::class, - // Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - - /* - * Package Service Providers... - */ - - /* - * Application Service Providers... - */ - App\Providers\ThemeServiceProvider::class, - - ], - - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ - - 'aliases' => [ - - 'App' => Illuminate\Support\Facades\App::class, - 'Arr' => Illuminate\Support\Arr::class, - // 'Artisan' => Illuminate\Support\Facades\Artisan::class, - // 'Auth' => Illuminate\Support\Facades\Auth::class, - 'Blade' => Illuminate\Support\Facades\Blade::class, - // 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, - 'Cache' => Illuminate\Support\Facades\Cache::class, - 'Config' => Illuminate\Support\Facades\Config::class, - // 'Cookie' => Illuminate\Support\Facades\Cookie::class, - // 'Crypt' => Illuminate\Support\Facades\Crypt::class, - // 'DB' => Illuminate\Support\Facades\DB::class, - // 'Eloquent' => Illuminate\Database\Eloquent\Model::class, - 'Event' => Illuminate\Support\Facades\Event::class, - 'File' => Illuminate\Support\Facades\File::class, - // 'Gate' => Illuminate\Support\Facades\Gate::class, - // 'Hash' => Illuminate\Support\Facades\Hash::class, - // 'Http' => Illuminate\Support\Facades\Http::class, - // 'Lang' => Illuminate\Support\Facades\Lang::class, - 'Log' => Illuminate\Support\Facades\Log::class, - // 'Mail' => Illuminate\Support\Facades\Mail::class, - // 'Notification' => Illuminate\Support\Facades\Notification::class, - // 'Password' => Illuminate\Support\Facades\Password::class, - // 'Queue' => Illuminate\Support\Facades\Queue::class, - // 'Redirect' => Illuminate\Support\Facades\Redirect::class, - // 'Redis' => Illuminate\Support\Facades\Redis::class, - // 'Request' => Illuminate\Support\Facades\Request::class, - // 'Response' => Illuminate\Support\Facades\Response::class, - // 'Route' => Illuminate\Support\Facades\Route::class, - // 'Schema' => Illuminate\Support\Facades\Schema::class, - // 'Session' => Illuminate\Support\Facades\Session::class, - 'Storage' => Illuminate\Support\Facades\Storage::class, - 'Str' => Illuminate\Support\Str::class, - // 'URL' => Illuminate\Support\Facades\URL::class, - // 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class, - - ], - -]; diff --git a/config/assets.php b/config/assets.php deleted file mode 100644 index 6e10186..0000000 --- a/config/assets.php +++ /dev/null @@ -1,41 +0,0 @@ - 'theme', - - /* - |-------------------------------------------------------------------------- - | Assets Manifests - |-------------------------------------------------------------------------- - | - | Manifests contain lists of assets that are referenced by static keys that - | point to dynamic locations, such as a cache-busted location. We currently - | support two types of manifest: - | - | assets: key-value pairs to match assets to their revved counterparts - | - | bundles: a series of entrypoints for loading bundles - | - */ - - 'manifests' => [ - 'theme' => [ - 'path' => get_theme_file_path('public'), - 'url' => get_theme_file_uri('public'), - 'assets' => public_path('manifest.json'), - 'bundles' => public_path('entrypoints.json'), - ] - ] -]; diff --git a/config/filesystems.php b/config/filesystems.php deleted file mode 100644 index d700035..0000000 --- a/config/filesystems.php +++ /dev/null @@ -1,66 +0,0 @@ - env('FILESYSTEM_DRIVER', 'local'), - - /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been setup for each driver as an example of the required options. - | - | Supported Drivers: "local", "ftp", "sftp", "s3" - | - */ - - 'disks' => [ - - 'local' => [ - 'driver' => 'local', - 'root' => WP_CONTENT_DIR, - ], - - 'wordpress' => [ - 'driver' => 'local', - 'root' => ABSPATH, - 'url' => site_url(), - 'visibility' => 'public', - ], - - 'theme' => [ - 'driver' => 'local', - 'root' => get_theme_file_path(), - 'url' => get_theme_file_uri(), - 'visibility' => 'public', - ], - - 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), - ], - - ], - -]; diff --git a/config/logging.php b/config/logging.php deleted file mode 100644 index f64e29c..0000000 --- a/config/logging.php +++ /dev/null @@ -1,106 +0,0 @@ - env('LOG_CHANNEL', 'stack'), - - /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, the framework uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | - */ - - 'channels' => [ - 'stack' => [ - 'driver' => 'stack', - 'channels' => ['daily'], - 'ignore_exceptions' => false, - ], - - 'single' => [ - 'driver' => 'single', - 'path' => storage_path('logs/application.log'), - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'daily' => [ - 'driver' => 'daily', - 'path' => storage_path('logs/application.log'), - 'level' => env('LOG_LEVEL', 'debug'), - 'days' => 14, - ], - - 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Application Log', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - ], - - 'papertrail' => [ - 'driver' => 'monolog', - 'level' => env('LOG_LEVEL', 'debug'), - 'handler' => SyslogUdpHandler::class, - 'handler_with' => [ - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), - ], - ], - - 'stderr' => [ - 'driver' => 'monolog', - 'handler' => StreamHandler::class, - 'formatter' => env('LOG_STDERR_FORMATTER'), - 'with' => [ - 'stream' => 'php://stderr', - ], - ], - - 'syslog' => [ - 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'errorlog' => [ - 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), - ], - - 'null' => [ - 'driver' => 'monolog', - 'handler' => NullHandler::class, - ], - - 'emergency' => [ - 'path' => storage_path('logs/application.log'), - ], - ], - -]; diff --git a/config/view.php b/config/view.php deleted file mode 100755 index 6bacf98..0000000 --- a/config/view.php +++ /dev/null @@ -1,81 +0,0 @@ - [ - get_theme_file_path('/resources/views'), - get_parent_theme_file_path('/resources/views'), - resource_path('views'), - ], - - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the uploads - | directory. However, as usual, you are free to change this value. - | - */ - - 'compiled' => WP_CONTENT_DIR . '/cache/acorn/views', - - /* - |-------------------------------------------------------------------------- - | View Debugger - |-------------------------------------------------------------------------- - | - | Enabling this option will display the current view name and data. Giving - | it a value of 'view' will only display view names. Giving it a value of - | 'data' will only display current data. Giving it any other truthy value - | will display both. - | - */ - - 'debug' => false, - - /* - |-------------------------------------------------------------------------- - | View Namespaces - |-------------------------------------------------------------------------- - | - | Blade has an underutilized feature that allows developers to add - | supplemental view paths that may contain conflictingly named views. - | These paths are prefixed with a namespace to get around the conflicts. - | A use case might be including views from within a plugin folder. - | - */ - - 'namespaces' => [ - /* - | Given the below example, in your views use something like: - | @include('MyPlugin::some.view.or.partial.here') - */ - // 'MyPlugin' => WP_PLUGIN_DIR . '/my-plugin/resources/views', - ], - - /* - |-------------------------------------------------------------------------- - | View Directives - |-------------------------------------------------------------------------- - | - | The namespaces where view components reside. Components can be referenced - | with camelCase & dot notation. - | - */ - - 'directives' => [ - // 'foo' => App\View\FooDirective::class, - ], -]; diff --git a/functions.php b/functions.php index 81b7e09..b0b5905 100644 --- a/functions.php +++ b/functions.php @@ -19,13 +19,50 @@ require $composer; /* |-------------------------------------------------------------------------- -| Run The Theme +| Register The Bootloader |-------------------------------------------------------------------------- | -| Once we have the theme booted, we can handle the incoming request using -| the application's HTTP kernel. Then, we will send the response back -| to this client's browser, allowing them to enjoy our application. +| The first thing we will do is schedule a new Acorn application container +| to boot when WordPress is finished loading the theme. The application +| serves as the "glue" for all the components of Laravel and is +| the IoC container for the system binding all of the various parts. | */ -require_once __DIR__ . '/bootstrap/app.php'; +\Roots\bootloader(); + +/* +|-------------------------------------------------------------------------- +| Register Sage Theme Files +|-------------------------------------------------------------------------- +| +| Out of the box, Sage ships with categorically named theme files +| containing common functionality and setup to be bootstrapped with your +| theme. Simply add (or remove) files from the array below to change what +| is registered alongside Sage. +| +*/ + +collect(['helpers', 'setup', 'filters']) + ->each(function ($file) { + if (! locate_template($file = "app/{$file}.php", true, true)) { + wp_die( + /* translators: %s is replaced with the relative file path */ + sprintf(__('Error locating %s for inclusion.', 'sage'), $file) + ); + } + }); + +/* +|-------------------------------------------------------------------------- +| Enable Sage Theme Support +|-------------------------------------------------------------------------- +| +| Once our theme files are registered and available for use, we are almost +| ready to boot our application. But first, we need to signal to Acorn +| that we will need to initialize the necessary service providers built in +| for Sage when booting. +| +*/ + +add_theme_support('sage'); diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore deleted file mode 100644 index 01e4a6c..0000000 --- a/storage/framework/cache/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!data/ -!.gitignore diff --git a/storage/framework/cache/data/.gitignore b/storage/framework/cache/data/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/storage/framework/cache/data/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/storage/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore