Improve wp acorn compability
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
.env
|
||||
/vendor
|
||||
.phpunit.result.cache
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# CLAUDE.md
|
||||
|
||||
Guidance for working in this repository.
|
||||
|
||||
## What this is
|
||||
|
||||
A **starter WordPress plugin** built on the [Roots Acorn](https://roots.io/acorn/)
|
||||
framework (Laravel components inside WordPress) with **Livewire 4** for reactive
|
||||
front-end components. It is a scaffold/template designed to **coexist with other
|
||||
Acorn-based plugins** in the same WordPress install without booting the framework
|
||||
more than once.
|
||||
|
||||
- `roots/acorn: ^6.0`, `livewire/livewire: ^4.1`
|
||||
- Requires PHP 8.4, WordPress 5.2+
|
||||
- PSR-4: `AcornPlugin\` → `app/`, `AcornPlugin\Tests\` → `tests/`
|
||||
- Acorn is bundled (in `vendor/`); the plugin `wp_die`s if `Roots\Acorn\Application`
|
||||
is somehow absent.
|
||||
|
||||
## The single-Acorn contract (read this before touching `bootstrap.php`)
|
||||
|
||||
PHP classes and the Acorn container are **global to a request**. If two Acorn
|
||||
plugins each call `Application::configure()->boot()`, the second clobbers the
|
||||
first. This plugin avoids that with a cooperative **boot election** that every
|
||||
Acorn plugin in the install must follow:
|
||||
|
||||
1. **One booter per request, elected via a shared action.** On `after_setup_theme`
|
||||
priority 0, a plugin boots Acorn only if `did_action('acorn/booted')` is false,
|
||||
then fires `do_action('acorn/booted')`; otherwise it stands down. This lives in
|
||||
`app/Acorn/BootCoordinator.php` (`BootCoordinator::BOOTED_ACTION = 'acorn/booted'`).
|
||||
`did_action()` is used deliberately — it is a **read-only** probe, unlike
|
||||
`Application::getInstance()`, which force-creates and installs an empty container.
|
||||
2. **Providers are auto-discovered, never hand-registered.** Each plugin declares
|
||||
its provider in `composer.json` under `extra.acorn.providers`. Whichever plugin
|
||||
wins the election scans **all** active plugins' manifests and registers every
|
||||
provider — so a plugin's provider boots even when a *sibling* booted Acorn.
|
||||
3. **Livewire assets are emitted once, by the boot owner.** Only the elected booter
|
||||
calls `LivewireAssets::registerOnce()` (`@livewireStyles` on `wp_head`,
|
||||
`@livewireScripts` on `wp_footer`). Livewire 4 self-initialises — never add
|
||||
`Livewire.start()` or a hand-rolled ESM `<script import>` per plugin.
|
||||
|
||||
**Rules for every Acorn plugin sharing this install (including siblings like
|
||||
`siteminder-integration`):**
|
||||
- Use the **exact action name `acorn/booted`** — it is the cross-plugin contract.
|
||||
- Give the plugin its **own PSR-4 namespace** (do *not* reuse `AcornPlugin\`), or
|
||||
`BootCoordinator`/`LivewireAssets`/provider classes collide by FQCN (first
|
||||
autoloader wins).
|
||||
- Namespace your views (`loadViewsFrom($path, 'your-plugin')`) and Livewire
|
||||
components (`Livewire::addNamespace('your-plugin', …)`) so they don't collide in
|
||||
the shared container.
|
||||
- Keep all co-installed Acorn plugins on the **same Acorn major version** — they
|
||||
share one bundled copy at runtime (first loaded wins).
|
||||
|
||||
**Caveat:** the election only coordinates plugins that adopt this contract. A Sage
|
||||
theme (or anything else) that boots Acorn will *not* fire `acorn/booted`, so the
|
||||
plugins would boot a second container on top of it. If a Sage theme is ever added,
|
||||
make the **theme** the sole booter and let plugins rely on `extra.acorn.providers`
|
||||
auto-discovery alone — drop the `configure()->boot()` from the plugins.
|
||||
|
||||
## Layout
|
||||
|
||||
- `index.php` — plugin header; includes `bootstrap.php`.
|
||||
- `bootstrap.php` — runs the boot election (above); on win, boots Acorn with
|
||||
`->withRouting(wordpress: true)` and emits Livewire assets once. **No**
|
||||
`withProviders()` — auto-discovery handles providers.
|
||||
- `app/Acorn/BootCoordinator.php` — the election seam (unit-tested).
|
||||
- `app/Acorn/LivewireAssets.php` — once-only Livewire asset emission.
|
||||
- `app/Providers/PluginServiceProvider.php` — registers namespaced views, the
|
||||
`acorn-starter` Livewire namespace, and the `[acorn_hello]` shortcode. Extends
|
||||
`Illuminate\Support\ServiceProvider` (Acorn's `ServiceProvider` is `final` in v6).
|
||||
- `resources/views/` — `hello-world.blade.php` (mounts `<livewire:acorn-starter::say-hello />`),
|
||||
`components/say-hello.blade.php` (anonymous single-file Livewire component).
|
||||
- `tests/` — PHPUnit + Brain\Monkey unit tests (`tests/Acorn/BootCoordinatorTest.php`).
|
||||
- `storage/framework/` — compiled views / cache / sessions (gitignored runtime dirs).
|
||||
- `.env` — `APP_KEY` (generate with `wp acorn key:generate`).
|
||||
|
||||
There is **no plugin-level `config/`**: a plugin shouldn't own the framework's
|
||||
global config, so the elected booter uses Acorn's defaults. Add config only if this
|
||||
plugin is intentionally the sole booter.
|
||||
|
||||
## Conventions
|
||||
|
||||
- New classes go under `app/` in the `AcornPlugin\` namespace.
|
||||
- Reference views by their namespace: `view('acorn-starter::…')`.
|
||||
- Naming: kebab (`acorn-starter`) for view/Livewire namespaces; the public shortcode
|
||||
stays `acorn_hello` (snake) as a published API.
|
||||
- Match the test style in `tests/` (Brain\Monkey, AAA, `test_` snake_case methods).
|
||||
|
||||
## Commands
|
||||
|
||||
- `composer install` — install deps (runs Acorn's `post-autoload-dump`, which
|
||||
rebuilds the package-discovery manifest; rerun after editing `extra.acorn.providers`).
|
||||
- `composer test` — PHPUnit unit suite.
|
||||
- `composer lint` — phpcs (PSR-12 + WordPress security/i18n sniffs).
|
||||
- `wp acorn …` — Acorn WP-CLI (e.g. `wp acorn key:generate`, `wp acorn package:discover`).
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace AcornPlugin\Acorn;
|
||||
|
||||
/**
|
||||
* Elects a single Acorn booter per request across all Acorn plugins.
|
||||
*
|
||||
* did_action() is a read-only probe of WordPress' action bookkeeping — unlike
|
||||
* Roots\Acorn\Application::getInstance(), which force-creates and installs an
|
||||
* empty container as the global singleton. The action name is a cross-plugin
|
||||
* contract: every Acorn plugin in the installation must use the same.
|
||||
*/
|
||||
final class BootCoordinator
|
||||
{
|
||||
public const BOOTED_ACTION = 'acorn/booted';
|
||||
|
||||
public function shouldBoot(): bool
|
||||
{
|
||||
return ! did_action(self::BOOTED_ACTION);
|
||||
}
|
||||
|
||||
public function markBooted(): void
|
||||
{
|
||||
// Deliberately unprefixed: BOOTED_ACTION is a shared cross-plugin
|
||||
// contract, so every cooperating Acorn plugin fires the same hook.
|
||||
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound
|
||||
do_action(self::BOOTED_ACTION);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace AcornPlugin\Acorn;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
|
||||
/**
|
||||
* Emits Livewire's frontend assets exactly once, from the plugin that owns the
|
||||
* Acorn boot. Livewire v4's @livewireScripts self-initialises from the data-*
|
||||
* attributes on the injected script.
|
||||
* WordPress never dispatches Laravel's RequestHandled event, so the
|
||||
* directives must be echoed into wp_head/wp_footer by hand.
|
||||
*/
|
||||
final class LivewireAssets
|
||||
{
|
||||
public static function registerOnce(): void
|
||||
{
|
||||
// Livewire renders its own trusted <style>/<script> markup — escaping it
|
||||
// would corrupt the output, so the EscapeOutput sniff is suppressed here.
|
||||
add_action('wp_head', static function (): void {
|
||||
echo Blade::render('@livewireStyles'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
});
|
||||
|
||||
add_action('wp_footer', static function (): void {
|
||||
echo Blade::render('@livewireScripts'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace AcornPlugin\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Livewire\Livewire;
|
||||
|
||||
/**
|
||||
* Registers this plugin's views, Livewire component and shortcode against the
|
||||
* shared Acorn container. Auto-discovered via composer.json extra.acorn.providers,
|
||||
* so it is registered by whichever plugin boots Acorn. Everything is namespaced,
|
||||
* so the plugin coexists with other Acorn plugins in the same container.
|
||||
*
|
||||
* Extends Illuminate\Support\ServiceProvider (not Roots\Acorn\ServiceProvider,
|
||||
* which is `final` in Acorn v6 and exists only to expose defaultProviders()).
|
||||
* Acorn's own providers (Sage, Assets, View …) all extend the Illuminate base,
|
||||
* which carries the protected loadViewsFrom() helper this provider relies on.
|
||||
*/
|
||||
class PluginServiceProvider extends ServiceProvider
|
||||
{
|
||||
/** Shared kebab prefix for this plugin's Blade + Livewire namespaces. */
|
||||
private const NAMESPACE = 'acorn-starter';
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->loadViewsFrom($this->resourcePath('views'), self::NAMESPACE);
|
||||
$this->registerLivewireComponents();
|
||||
$this->registerShortcodes();
|
||||
}
|
||||
|
||||
private function registerLivewireComponents(): void
|
||||
{
|
||||
if (! class_exists(Livewire::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Livewire::addNamespace(self::NAMESPACE, $this->resourcePath('views/components'));
|
||||
}
|
||||
|
||||
private function registerShortcodes(): void
|
||||
{
|
||||
add_shortcode('acorn_hello', fn () => view(self::NAMESPACE . '::hello-world')->render());
|
||||
}
|
||||
|
||||
private function resourcePath(string $path = ''): string
|
||||
{
|
||||
return dirname(__DIR__, 2) . '/resources/' . ltrim($path, '/');
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
per aspera ad astra.
|
||||
+20
-23
@@ -1,42 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use AcornPlugin\Acorn\BootCoordinator;
|
||||
use AcornPlugin\Acorn\LivewireAssets;
|
||||
use Roots\Acorn\Application;
|
||||
|
||||
include_once 'vendor/autoload.php';
|
||||
include_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Plugin requires WP Acorn
|
||||
if (! class_exists( Application::class)) {
|
||||
if (! class_exists(Application::class)) {
|
||||
wp_die(
|
||||
__('You need to install Acorn to use this site.', 'domain'),
|
||||
esc_html__('You need to install Acorn to use this site.', 'acorn-starter'),
|
||||
'',
|
||||
[
|
||||
'link_url' => 'https://roots.io/acorn/docs/installation/',
|
||||
'link_text' => __('Acorn Docs: Installation', 'domain'),
|
||||
'link_text' => esc_html__('Acorn Docs: Installation', 'acorn-starter'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
add_action('after_setup_theme', function () {
|
||||
$coordinator = new BootCoordinator();
|
||||
|
||||
// Another Acorn plugin already booted the framework this request. Our
|
||||
// provider is auto-discovered (composer.json extra.acorn.providers), so
|
||||
// there is nothing left to do.
|
||||
if (! $coordinator->shouldBoot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Application::configure()
|
||||
->withProviders([
|
||||
|
||||
])
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
|
||||
})
|
||||
->withRouting(wordpress: true)
|
||||
->boot();
|
||||
|
||||
$coordinator->markBooted();
|
||||
|
||||
// Livewire assets are a global concern — emit once, from the elected owner.
|
||||
LivewireAssets::registerOnce();
|
||||
}, 0);
|
||||
|
||||
// Insert code injection to the document head
|
||||
add_action('wp_head', function () {
|
||||
echo view('injections.head')->render();
|
||||
});
|
||||
|
||||
// Insert code injection to the document footer
|
||||
add_action('wp_footer', function () {
|
||||
echo view('injections.footer')->render();
|
||||
});
|
||||
|
||||
+35
-1
@@ -1,16 +1,50 @@
|
||||
{
|
||||
"require": {
|
||||
"roots/acorn": "^5.0",
|
||||
"roots/acorn": "^6.0",
|
||||
"livewire/livewire": "^4.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"brain/monkey": "^2.6",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
||||
"mockery/mockery": "^1.6",
|
||||
"phpcompatibility/phpcompatibility-wp": "^2.1",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"squizlabs/php_codesniffer": "^3.10",
|
||||
"wp-coding-standards/wpcs": "^3.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AcornPlugin\\": "app/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"AcornPlugin\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"acorn": {
|
||||
"providers": [
|
||||
"AcornPlugin\\Providers\\PluginServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Roots\\Acorn\\ComposerScripts::postAutoloadDump"
|
||||
],
|
||||
"lint": [
|
||||
"@php vendor/bin/phpcs"
|
||||
],
|
||||
"test": [
|
||||
"@php vendor/bin/phpunit"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/installers": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+3610
-891
File diff suppressed because it is too large
Load Diff
-126
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Acorn'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', home_url()),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', get_locale()),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -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' => get_theme_file_path('public/manifest.json'),
|
||||
'bundles' => get_theme_file_path('public/entrypoints.json'),
|
||||
],
|
||||
],
|
||||
];
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
@@ -1,193 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'wordpress'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => null,
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
],
|
||||
|
||||
'wordpress' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => DB_HOST,
|
||||
'database' => DB_NAME,
|
||||
'username' => DB_USER,
|
||||
'password' => DB_PASSWORD,
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => DB_CHARSET,
|
||||
'collation' => $GLOBALS['wpdb']->collate,
|
||||
'prefix' => $GLOBALS['wpdb']->prefix,
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
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 for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'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'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Acorn command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_KEY'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,217 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Storage Paths
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Most templating systems load templates from disk. Here you may specify
|
||||
| an array of paths that should be checked for your views. Of course
|
||||
| the usual view paths have already been registered for you.
|
||||
|
|
||||
*/
|
||||
|
||||
'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 storage
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => env('VIEW_COMPILED_PATH', storage_path('framework/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,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: Acorn Plugin
|
||||
* Description: Start für ein Acorn Wordpress Plugin
|
||||
@@ -9,13 +10,6 @@
|
||||
* Author URI: https://loosen-it.de
|
||||
*/
|
||||
|
||||
include_once 'bootstrap.php';
|
||||
|
||||
$renderHello = function () {
|
||||
if (function_exists('view')) {
|
||||
return view('hello-world')->render();
|
||||
}
|
||||
|
||||
return 'Hello World';
|
||||
};
|
||||
add_shortcode('acorn_hello', $renderHello);
|
||||
// The boot election lives in bootstrap.php; the shortcode, namespaced views and
|
||||
// Livewire registration live in AcornPlugin\Providers\PluginServiceProvider.
|
||||
include_once __DIR__ . '/bootstrap.php';
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="acorn-starter">
|
||||
<description>WordPress Coding Standards for acorn-starter.</description>
|
||||
|
||||
<file>app</file>
|
||||
<file>resources/views</file>
|
||||
<file>index.php</file>
|
||||
<file>bootstrap.php</file>
|
||||
|
||||
<exclude-pattern>/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>/node_modules/*</exclude-pattern>
|
||||
|
||||
<arg value="sp"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="basepath" value="."/>
|
||||
<arg name="parallel" value="8"/>
|
||||
|
||||
<!-- PSR-12 is the house style (spaces, short arrays, no Yoda). -->
|
||||
<rule ref="PSR12"/>
|
||||
|
||||
<!-- Keep the WordPress sniffs that catch real bugs, not house style. -->
|
||||
<rule ref="WordPress.Security"/>
|
||||
<rule ref="WordPress.DB.PreparedSQL"/>
|
||||
<rule ref="WordPress.DB.PreparedSQLPlaceholders"/>
|
||||
<rule ref="WordPress.WP.AlternativeFunctions"/>
|
||||
<rule ref="WordPress.WP.GlobalVariablesOverride"/>
|
||||
|
||||
<!-- We use PSR-4 file naming (Foo.php), not WPCS's class-foo.php convention. -->
|
||||
<rule ref="WordPress.Files.FileName">
|
||||
<properties>
|
||||
<property name="strict_class_file_names" value="false"/>
|
||||
</properties>
|
||||
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress.WP.I18n">
|
||||
<properties>
|
||||
<property name="text_domain" type="array">
|
||||
<element value="acorn-starter"/>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
|
||||
<properties>
|
||||
<property name="prefixes" type="array">
|
||||
<element value="acorn_starter"/>
|
||||
<element value="AcornPlugin"/>
|
||||
<element value="ACORN_STARTER"/>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
Blade view templates use locally-scoped template variables and inline
|
||||
echo, which PSR-12's brace sniffs and the "prefix all globals" sniff are
|
||||
not designed for. Scope those out for views only; the sniffs that actually
|
||||
matter for templates (output escaping, i18n, input validation, real WP
|
||||
global collisions) stay active.
|
||||
-->
|
||||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
|
||||
<exclude-pattern>resources/views/*</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ControlSignature">
|
||||
<exclude-pattern>resources/views/*</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
|
||||
<exclude-pattern>resources/views/*</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<exclude-pattern>resources/views/*</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
The plugin entry files are the textbook PSR1 exception: index.php carries
|
||||
the plugin header and includes bootstrap.php; bootstrap.php boots the
|
||||
framework and registers hooks. Declaring symbols and causing side effects
|
||||
in one file is expected for these entry points, as it is for Blade views.
|
||||
-->
|
||||
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
|
||||
<exclude-pattern>index.php</exclude-pattern>
|
||||
<exclude-pattern>bootstrap.php</exclude-pattern>
|
||||
<exclude-pattern>resources/views/*</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<!-- Pure-markup Blade partials (e.g. hello-world.blade.php) legitimately
|
||||
contain no PHP; the "no code found" notice does not apply to them. -->
|
||||
<rule ref="Internal.NoCodeFound">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<config name="testVersion" value="8.2-"/>
|
||||
<rule ref="PHPCompatibilityWP"/>
|
||||
</ruleset>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
cacheResultFile=".phpunit.result.cache">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
@@ -6,7 +6,8 @@ new class extends Component
|
||||
{
|
||||
public string $content = '';
|
||||
|
||||
public function sayHello(): void {
|
||||
public function sayHello(): void
|
||||
{
|
||||
$this->content = 'Hello World by Livewire Wordpress Stack!';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<div>
|
||||
<livewire:say-hello />
|
||||
<livewire:acorn-starter::say-hello />
|
||||
</div>
|
||||
@@ -1,2 +0,0 @@
|
||||
<!-- Livewire Config -->
|
||||
@livewireScriptConfig
|
||||
@@ -1,8 +0,0 @@
|
||||
@php($livewireUrl = plugins_url('village-archive/vendor/livewire/livewire/dist/livewire.esm.js'))
|
||||
|
||||
<script type="module">
|
||||
import { Livewire } from '{{ $livewireUrl }}';
|
||||
Livewire.start();
|
||||
</script>
|
||||
|
||||
@livewireStyles
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace AcornPlugin\Tests\Acorn;
|
||||
|
||||
use AcornPlugin\Acorn\BootCoordinator;
|
||||
use AcornPlugin\Tests\TestCase;
|
||||
use Brain\Monkey\Functions;
|
||||
|
||||
final class BootCoordinatorTest extends TestCase
|
||||
{
|
||||
// -----------------------------------------------------------------------
|
||||
// shouldBoot()
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function test_should_boot_returns_true_when_action_has_not_fired(): void
|
||||
{
|
||||
Functions\when('did_action')->justReturn(0);
|
||||
|
||||
$result = (new BootCoordinator())->shouldBoot();
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function test_should_boot_returns_false_when_action_already_fired(): void
|
||||
{
|
||||
Functions\expect('did_action')
|
||||
->once()
|
||||
->with(BootCoordinator::BOOTED_ACTION)
|
||||
->andReturn(1);
|
||||
|
||||
$result = (new BootCoordinator())->shouldBoot();
|
||||
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// markBooted()
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function test_mark_booted_fires_the_booted_action_once(): void
|
||||
{
|
||||
Functions\expect('do_action')
|
||||
->once()
|
||||
->with(BootCoordinator::BOOTED_ACTION);
|
||||
|
||||
(new BootCoordinator())->markBooted();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace AcornPlugin\Tests;
|
||||
|
||||
use Brain\Monkey;
|
||||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
||||
use PHPUnit\Framework\TestCase as PhpUnitTestCase;
|
||||
|
||||
abstract class TestCase extends PhpUnitTestCase
|
||||
{
|
||||
// Bridges Brain\Monkey's Mockery-backed expectations into PHPUnit's
|
||||
// assertion count, so expectation-only tests aren't reported as "risky".
|
||||
use MockeryPHPUnitIntegration;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Monkey\setUp();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Monkey\tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* WordPress isn't loaded in unit tests. Define ABSPATH as insurance so any code
|
||||
* that transitively pulls in a file guarded by `defined('ABSPATH') || exit;`
|
||||
* fails loudly instead of vanishing mid-load. BootCoordinator itself needs no WP
|
||||
* constants — Brain\Monkey mocks did_action()/do_action() per test.
|
||||
*/
|
||||
if (! defined('ABSPATH')) {
|
||||
define('ABSPATH', __DIR__ . '/');
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
Reference in New Issue
Block a user