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 <hi@qwp6t.me>
This commit is contained in:
Ben Word
2021-12-29 15:42:29 -06:00
committed by GitHub
parent 85db9c25ca
commit ed8a80c052
13 changed files with 50 additions and 572 deletions

View File

@@ -91,21 +91,10 @@ themes/your-theme-name/ # → Root of your Sage based theme
├── app/ # → Theme PHP ├── app/ # → Theme PHP
│ ├── Providers/ # → Service providers │ ├── Providers/ # → Service providers
│ ├── View/ # → View models │ ├── View/ # → View models
│ ├── admin.php # → Theme customizer setup
│ ├── filters.php # → Theme filters │ ├── filters.php # → Theme filters
│ ├── helpers.php # → Helper functions │ ├── helpers.php # → Helper functions
│ └── setup.php # → Theme setup │ └── 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.json # → Autoloading for `app/` files
├── composer.lock # → Composer lock file (never edit)
├── public/ # → Built theme assets (never edit) ├── public/ # → Built theme assets (never edit)
├── functions.php # → Theme bootloader ├── functions.php # → Theme bootloader
├── index.php # → Theme template wrapper ├── index.php # → Theme template wrapper

View File

@@ -1,50 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Acorn application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
\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 <code>%s</code> 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');

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -59,10 +59,17 @@
"prefer-stable": true, "prefer-stable": true,
"scripts": { "scripts": {
"lint": [ "lint": [
"phpcs --extensions=php --standard=PSR12 app config" "phpcs --extensions=php --standard=PSR12 app"
], ],
"post-autoload-dump": [ "post-autoload-dump": [
"Roots\\Acorn\\ComposerScripts::postAutoloadDump" "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
] ]
},
"extra": {
"acorn": {
"providers": [
"App\\Providers\\ThemeServiceProvider"
]
}
} }
} }

View File

@@ -1,202 +0,0 @@
<?php
use function Roots\env;
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => 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,
],
];

View File

@@ -1,41 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Assets Manifest
|--------------------------------------------------------------------------
|
| Here you may specify the default asset manifest that should be used.
| The "theme" manifest is recommended as the default as it cedes ultimate
| authority of your application's assets to the theme.
|
*/
'default' => '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'),
]
]
];

View File

@@ -1,66 +0,0 @@
<?php
use function Roots\env;
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => 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'),
],
],
];

View File

@@ -1,106 +0,0 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use function Roots\env;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => 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'),
],
],
];

View File

@@ -1,81 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most template systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views.
|
*/
'paths' => [
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,
],
];

View File

@@ -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 first thing we will do is schedule a new Acorn application container
| the application's HTTP kernel. Then, we will send the response back | to boot when WordPress is finished loading the theme. The application
| to this client's browser, allowing them to enjoy our 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 <code>%s</code> 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');

View File

@@ -1,3 +0,0 @@
*
!data/
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -1,2 +0,0 @@
*
!.gitignore