chore: Refactor configuration files based on Laravel 10 skeleton

This commit is contained in:
Jonny Barnes 2023-06-09 18:31:53 +01:00
commit bebbfec510
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
35 changed files with 203 additions and 282 deletions

View file

@ -1,9 +1,5 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true root = true
# Unix-style newlines with a newline ending every file
[*] [*]
charset = utf-8 charset = utf-8
end_of_line = lf end_of_line = lf
@ -12,11 +8,6 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
# Tab indentation
[Makefile]
indent_style = tab
tab_width = 4
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false

14
.gitattributes vendored
View file

@ -1,5 +1,11 @@
* text=auto * text=auto eol=lf
*.css linguist-vendored
*.scss linguist-vendored *.blade.php diff=html
*.js linguist-vendored *.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore CHANGELOG.md export-ignore
.styleci.yml export-ignore

23
.gitignore vendored
View file

@ -1,22 +1,23 @@
/.phpunit.cache
/node_modules /node_modules
/public/build
/public/coverage
/public/hot
/public/files
/public/fonts
/public/storage
/storage/*.key /storage/*.key
/vendor /vendor
.env .env
.env.backup
.env.production
.phpunit.result.cache .phpunit.result.cache
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
auth.json
npm-debug.log npm-debug.log
yarn-error.log yarn-error.log
/.fleet
/.idea /.idea
/lsp /.vscode
.phpstorm.meta.php
_ide_helper.php
ray.php ray.php
# Custom paths in /public
/public/coverage
/public/hot
/public/storage
/public/fonts
/public/files
/public/keybase.txt
/public/assets/*.map

View file

@ -1,8 +1,9 @@
preset: laravel php:
preset: laravel
disabled: disabled:
- concat_without_spaces - no_unused_imports
- single_import_per_statement finder:
not-name:
finder: - index.php
path: app/ js: true
css: true

View file

@ -7,20 +7,8 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/**
* The Artisan commands provided by your application.
*
* @var array<int, string>
*/
protected $commands = [
Commands\ParseCachedWebMentions::class,
Commands\ReDownloadWebMentions::class,
];
/** /**
* Define the application's command schedule. * Define the application's command schedule.
*
* @codeCoverageIgnore
*/ */
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
@ -33,7 +21,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands(): void protected function commands(): void
{ {
$this->load(__DIR__ . '/Commands'); $this->load(__DIR__.'/Commands');
require base_path('routes/console.php'); require base_path('routes/console.php');
} }

View file

@ -3,13 +3,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {
use AuthorizesRequests; use AuthorizesRequests, ValidatesRequests;
use DispatchesJobs;
use ValidatesRequests;
} }

View file

@ -152,7 +152,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [
@ -188,7 +188,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [

View file

@ -45,7 +45,7 @@ class TokenEndpointController extends Controller
public function create(Request $request): JsonResponse public function create(Request $request): JsonResponse
{ {
$auth = $this->verifyIndieAuthCode( $auth = $this->verifyIndieAuthCode(
config('app.authorization_endpoint'), config('url.authorization_endpoint'),
$request->input('code'), $request->input('code'),
$request->input('redirect_uri'), $request->input('redirect_uri'),
$request->input('client_id'), $request->input('client_id'),

View file

@ -33,13 +33,11 @@ class Kernel extends HttpKernel
\App\Http\Middleware\EncryptCookies::class, \App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class, \Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\LinkHeadersMiddleware::class, \App\Http\Middleware\LinkHeadersMiddleware::class,
\App\Http\Middleware\LocalhostSessionMiddleware::class, \App\Http\Middleware\LocalhostSessionMiddleware::class,
\App\Http\Middleware\ActivityStreamLinks::class,
\App\Http\Middleware\CSPHeader::class, \App\Http\Middleware\CSPHeader::class,
], ],
@ -53,7 +51,7 @@ class Kernel extends HttpKernel
/** /**
* The application's middleware aliases. * The application's middleware aliases.
* *
* Aliases may be used to conveniently assign middleware to routes and groups. * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
* *
* @var array<string, class-string|string> * @var array<string, class-string|string>
*/ */
@ -65,7 +63,8 @@ class Kernel extends HttpKernel
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class, 'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class,

View file

@ -1,28 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ActivityStreamLinks
{
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
if ($request->path() === '/') {
$response->header('Link', '<' . config('app.url') . '>; rel="application/activity+json"', false);
}
if ($request->is('notes/*')) {
$response->header('Link', '<' . $request->url() . '>; rel="application/activity+json"', false);
}
return $response;
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

View file

@ -62,7 +62,7 @@ class SendWebMentions implements ShouldQueue
public function discoverWebmentionEndpoint(string $url): ?string public function discoverWebmentionEndpoint(string $url): ?string
{ {
// let’s not send webmentions to myself // let’s not send webmentions to myself
if (parse_url($url, PHP_URL_HOST) === config('app.longurl')) { if (parse_url($url, PHP_URL_HOST) === config('url.longurl')) {
return null; return null;
} }
if (Str::startsWith($url, '/notes/tagged/')) { if (Str::startsWith($url, '/notes/tagged/')) {

View file

@ -179,7 +179,7 @@ class Note extends Model
public function getShorturlAttribute(): string public function getShorturlAttribute(): string
{ {
return config('app.shorturl') . '/notes/' . $this->nb60id; return config('url.shorturl') . '/notes/' . $this->nb60id;
} }
public function getIso8601Attribute(): string public function getIso8601Attribute(): string

View file

@ -84,7 +84,7 @@ class Place extends Model
protected function shorturl(): Attribute protected function shorturl(): Attribute
{ {
return Attribute::get( return Attribute::get(
get: fn ($value, $attributes) => config('app.shorturl') . '/places/' . $attributes['slug'], get: fn ($value, $attributes) => config('url.shorturl') . '/places/' . $attributes['slug'],
); );
} }

View file

@ -2,6 +2,7 @@
namespace App\Providers; namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider
@ -12,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array<class-string, class-string> * @var array<class-string, class-string>
*/ */
protected $policies = [ protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy', //
]; ];
/** /**

View file

@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {
/** /**
* The path to the "home" route for your application. * The path to your application's "home" route.
* *
* Typically, users are redirected here after authentication. * Typically, users are redirected here after authentication.
* *
@ -24,7 +24,9 @@ class RouteServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
$this->configureRateLimiting(); RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
$this->routes(function () { $this->routes(function () {
Route::middleware('api') Route::middleware('api')
@ -35,14 +37,4 @@ class RouteServiceProvider extends ServiceProvider
->group(base_path('routes/web.php')); ->group(base_path('routes/web.php'));
}); });
} }
/**
* Configure the rate limiters for the application.
*/
protected function configureRateLimiting(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
} }

View file

@ -1,30 +1,26 @@
{ {
"name": "jonnybarnes/jonnybarnes.uk", "name": "jonnybarnes/jonnybarnes.uk",
"type": "project", "type": "project",
"description": "The code for jonnybarnes.uk, based on Laravel 8", "description": "The code for jonnybarnes.uk, based on Laravel 10",
"keywords": [ "keywords": ["laravel", "framework", "indieweb"],
"framework",
"laravel",
"indieweb"
],
"license": "CC0-1.0", "license": "CC0-1.0",
"require": { "require": {
"php": "^8.0", "php": "^8.1",
"ext-dom": "*", "ext-dom": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
"cviebrock/eloquent-sluggable": "^10.0", "cviebrock/eloquent-sluggable": "^10.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.2",
"indieauth/client": "^1.1", "indieauth/client": "^1.1",
"intervention/image": "^2.4", "intervention/image": "^2.4",
"jonnybarnes/indieweb": "~0.2", "jonnybarnes/indieweb": "~0.2",
"jonnybarnes/webmentions-parser": "~0.5", "jonnybarnes/webmentions-parser": "~0.5",
"jublonet/codebird-php": "4.0.0-beta.1", "jublonet/codebird-php": "4.0.0-beta.1",
"laravel/framework": "^10.0", "laravel/framework": "^10.10",
"laravel/horizon": "^5.0", "laravel/horizon": "^5.0",
"laravel/sanctum": "^3.0", "laravel/sanctum": "^3.2",
"laravel/scout": "^10.1", "laravel/scout": "^10.1",
"laravel/tinker": "^2.0", "laravel/tinker": "^2.8",
"lcobucci/jwt": "^5.0", "lcobucci/jwt": "^5.0",
"league/commonmark": "^2.0", "league/commonmark": "^2.0",
"league/flysystem-aws-s3-v3": "^3.0", "league/flysystem-aws-s3-v3": "^3.0",
@ -39,29 +35,15 @@
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"fakerphp/faker": "^1.9.2", "fakerphp/faker": "^1.9.2",
"laravel/dusk": "^7.0", "laravel/dusk": "^7.0",
"laravel/pint": "^1.0.0", "laravel/pint": "^1.0",
"laravel/sail": "^1.15", "laravel/sail": "^1.18",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0", "nunomaduro/collision": "^7.0",
"phpunit/php-code-coverage": "^10.0", "phpunit/php-code-coverage": "^10.0",
"phpunit/phpunit": "^10.0", "phpunit/phpunit": "^10.1",
"spatie/laravel-ray": "^1.12", "spatie/laravel-ray": "^1.12",
"vimeo/psalm": "^5.0" "vimeo/psalm": "^5.0"
}, },
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": false,
"composer/installers": false
}
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/", "App\\": "app/",
@ -74,24 +56,38 @@
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Tests\\": "tests" "Tests\\": "tests/"
} }
}, },
"minimum-stability": "stable",
"prefer-stable": true,
"scripts": { "scripts": {
"post-autoload-dump": [ "post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi" "@php artisan package:discover --ansi"
], ],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [ "post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
], ],
"post-create-project-cmd": [ "post-create-project-cmd": [
"@php artisan key:generate --ansi" "@php artisan key:generate --ansi"
],
"test": [
"vendor/bin/phpunit --stop-on-failure"
] ]
} },
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
} }

View file

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\Facade;
use Illuminate\Support\ServiceProvider;
return [ return [
@ -58,50 +59,6 @@ return [
'asset_url' => env('ASSET_URL'), 'asset_url' => env('ASSET_URL'),
/*
|--------------------------------------------------------------------------
| Application Long URL
|--------------------------------------------------------------------------
|
| The long URL for the application
|
*/
'longurl' => env('APP_LONGURL', 'longurl.local'),
/*
|--------------------------------------------------------------------------
| Application Short URL
|--------------------------------------------------------------------------
|
| The short URL for the application
|
*/
'shorturl' => env('APP_SHORTURL', 'shorturl.local'),
/*
|--------------------------------------------------------------------------
| Authorization endpoint
|--------------------------------------------------------------------------
|
| The authorization endpoint for the application, used primarily for Micropub
|
*/
'authorization_endpoint' => env('AUTHORIZATION_ENDPOINT', 'https://indieauth.com/auth'),
/*
|--------------------------------------------------------------------------
| Application Display Name
|--------------------------------------------------------------------------
|
| The display name for the application, used for example in titles.
|
*/
'display_name' => env('DISPLAY_NAME', 'Joe Bloggs'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Timezone | Application Timezone
@ -209,34 +166,7 @@ return [
| |
*/ */
'providers' => [ 'providers' => ServiceProvider::defaultProviders()->merge([
/*
* 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... * Package Service Providers...
*/ */
@ -248,10 +178,9 @@ return [
App\Providers\AuthServiceProvider::class, App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class, // App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\HorizonServiceProvider::class, App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class,
], ])->toArray(),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -265,7 +194,7 @@ return [
*/ */
'aliases' => Facade::defaultAliases()->merge([ 'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class, // 'Example' => App\Facades\Example::class,
])->toArray(), ])->toArray(),
]; ];

View file

@ -80,7 +80,7 @@ return [
| than one user table or model in the application and you want to have | than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types. | separate password reset settings based on the specific user types.
| |
| The expire time is the number of minutes that each reset token will be | The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so | considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed. | they have less time to be guessed. You may change this as needed.
| |

View file

@ -36,6 +36,7 @@ return [
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443), 'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'), 'scheme' => env('PUSHER_SCHEME', 'https'),

Some files were not shown because too many files have changed in this diff Show more