Skip to content

Commit

Permalink
Merge pull request #4 from learnhubdev/upgrade-the-project-to-php-ver…
Browse files Browse the repository at this point in the history
…sion-8.2-and-laravel-10

Update the project to PHP 8.2 and Laravel 10
  • Loading branch information
davorminchorov committed Apr 19, 2023
2 parents 4360005 + 52e4884 commit 8d353e7
Show file tree
Hide file tree
Showing 22 changed files with 994 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion App/Application/Members/SendMemberActivationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Queue\ShouldQueue;

final class SendMemberActivationEmail implements ShouldQueue
final readonly class SendMemberActivationEmail implements ShouldQueue
{
/**
* Create the event listener.
Expand Down
10 changes: 5 additions & 5 deletions App/Application/Members/SignUpMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace App\Application\Members;

final class SignUpMember
final readonly class SignUpMember
{
public function __construct(
public readonly string $firstName,
public readonly string $lastName,
public readonly string $emailAddress,
public readonly string $password
public string $firstName,
public string $lastName,
public string $emailAddress,
public string $password
) {
}
}
2 changes: 1 addition & 1 deletion App/Application/Members/SignUpMemberCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Illuminate\Contracts\Hashing\Hasher;
use Symfony\Component\Clock\ClockInterface;

final class SignUpMemberCommandHandler
final readonly class SignUpMemberCommandHandler
{
public function __construct(
private readonly MemberRepository $memberRepository,
Expand Down
18 changes: 9 additions & 9 deletions App/Domain/Members/MemberReadModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
use DateTimeImmutable;
use Exception;

final class MemberReadModel
final readonly class MemberReadModel
{
public function __construct(
public readonly Id $id,
public readonly FirstName $firstName,
public readonly LastName $lastName,
public readonly EmailAddress $emailAddress,
public readonly StatusName $status,
public readonly DateTimeImmutable $createdAt,
public readonly DateTimeImmutable $updatedAt,
public readonly ?DateTimeImmutable $emailVerifiedAt
public Id $id,
public FirstName $firstName,
public LastName $lastName,
public EmailAddress $emailAddress,
public StatusName $status,
public DateTimeImmutable $createdAt,
public DateTimeImmutable $updatedAt,
public ?DateTimeImmutable $emailVerifiedAt
) {
}

Expand Down
12 changes: 6 additions & 6 deletions App/Domain/Members/MemberSignedUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace App\Domain\Members;

final class MemberSignedUp
final readonly class MemberSignedUp
{
public function __construct(
public readonly Id $id,
public readonly FirstName $firstName,
public readonly LastName $lastName,
public readonly EmailAddress $emailAddress,
public readonly StatusName $status
public Id $id,
public FirstName $firstName,
public LastName $lastName,
public EmailAddress $emailAddress,
public StatusName $status
) {
//
}
Expand Down
4 changes: 2 additions & 2 deletions App/Domain/Members/MemberWasVerified.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace App\Domain\Members;

final class MemberWasVerified
final readonly class MemberWasVerified
{
public function __construct(public readonly \DateTimeImmutable $date)
public function __construct(public \DateTimeImmutable $date)
{
//
}
Expand Down
9 changes: 9 additions & 0 deletions App/Infrastructure/Laravel/Config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;

return [

Expand Down Expand Up @@ -61,13 +62,15 @@
'driver' => 'single',
'path' => storage_path(path: 'Logs/laravel.log'),
'level' => env(key: 'LOG_LEVEL', default: 'debug'),
'replace_placeholders' => true,
],

'daily' => [
'driver' => 'daily',
'path' => storage_path(path: 'Logs/laravel.log'),
'level' => env(key: 'LOG_LEVEL', default: 'debug'),
'days' => 14,
'replace_placeholders' => true,
],

'slack' => [
Expand All @@ -76,6 +79,7 @@
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env(key: 'LOG_LEVEL', default: 'critical'),
'replace_placeholders' => true,
],

'papertrail' => [
Expand All @@ -87,6 +91,7 @@
'port' => env(key: 'PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env(key: 'PAPERTRAIL_URL').':'.env(key: 'PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],

'stderr' => [
Expand All @@ -97,16 +102,20 @@
'with' => [
'stream' => 'php://stderr',
],
'processors' => [PsrLogMessageProcessor::class],
],

'syslog' => [
'driver' => 'syslog',
'level' => env(key: 'LOG_LEVEL', default: 'debug'),
'facility' => LOG_USER,
'replace_placeholders' => true,
],

'errorlog' => [
'driver' => 'errorlog',
'level' => env(key: 'LOG_LEVEL', default: 'debug'),
'replace_placeholders' => true,
],

'null' => [
Expand Down
8 changes: 7 additions & 1 deletion App/Infrastructure/Laravel/Config/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "log", "array", "failover"
|
*/
Expand All @@ -51,10 +51,16 @@

'mailgun' => [
'transport' => 'mailgun',
// 'client' => [
// 'timeout' => 5,
// ],
],

'postmark' => [
'transport' => 'postmark',
// 'client' => [
// 'timeout' => 5,
// ],
],

'sendmail' => [
Expand Down
16 changes: 16 additions & 0 deletions App/Infrastructure/Laravel/Config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@

],

/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env(key: 'DB_CONNECTION', default: 'mysql'),
'table' => 'job_batches',
],


/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
Expand Down
2 changes: 1 addition & 1 deletion App/Infrastructure/Laravel/Config/sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
|
*/

'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'stateful' => explode(',', (string) env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public function up(): void
{
Schema::create(table: 'password_resets', callback: function (Blueprint $table) {
Schema::create(table: 'password_reset_tokens', callback: function (Blueprint $table) {
$table->string(column: 'email', length: 200)->index();
$table->string(column: 'token');
$table->timestamp(column: 'created_at')->nullable();
Expand All @@ -25,6 +25,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists(table: 'password_resets');
Schema::dropIfExists(table: 'password_reset_tokens');
}
};
8 changes: 4 additions & 4 deletions App/Infrastructure/Laravel/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ class Kernel extends HttpKernel
],

'api' => [
'throttle:api',
ThrottleRequests::class.':api',
],
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => Authenticate::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
Expand Down
4 changes: 1 addition & 3 deletions App/Infrastructure/Laravel/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param Request $request
*/
protected function redirectTo($request): ?string
protected function redirectTo(Request $request): ?string
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class ModelFactoryServiceProvider extends ServiceProvider
*/
public function register(): void
{
Factory::guessFactoryNamesUsing(function (string $modelName) {
return $modelName.'Factory';
});
Factory::guessFactoryNamesUsing(fn(string $modelName) => $modelName.'Factory');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public function boot(): void
*/
protected function configureRateLimiting(): void
{
RateLimiter::for(name: 'api', callback: function (Request $request) {
return Limit::perMinute(maxAttempts: 60)->by(key: $request->user()?->id ?: $request->ip());
});
RateLimiter::for(name: 'api', callback: fn(Request $request) => Limit::perMinute(maxAttempts: 60)->by(key: $request->user()?->id ?: $request->ip()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function sign_up_member_validation_errors(string $field, mixed $value, st
->assertJsonValidationErrors(errors: $errorField ?: $field);
}

public function signUpMemberDataProvider(): array
public static function signUpMemberDataProvider(): array
{
return [
'The first name field is required' => ['first_name', ''],
Expand Down
2 changes: 1 addition & 1 deletion App/Infrastructure/Members/EloquentMemberRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Assert\AssertionFailedException;
use Godruoyi\Snowflake\Snowflake;

final class EloquentMemberRepository implements MemberRepository
final readonly class EloquentMemberRepository implements MemberRepository
{
public function __construct(private readonly MemberEloquentModel $member)
{
Expand Down
2 changes: 1 addition & 1 deletion App/Infrastructure/Members/SignUpMemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spatie\RouteAttributes\Attributes\Post;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;

final class SignUpMemberController
final readonly class SignUpMemberController
{
public function __construct(private readonly Dispatcher $commandBusDispatcher)
{
Expand Down
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "learnhubdev/laravel-api-starter-kit",
"type": "project",
"version": "0.1.1",
"version": "0.2.5",
"description": "A Laravel API Starter Kit for long-term projects inspired by the tactical patterns of Domain-Driven Design",
"keywords": ["framework", "laravel", "starter kit"],
"license": "MIT",
"require": {
"php": "^8.1.0",
"php": "^8.2.0",
"ext-pdo": "*",
"beberlei/assert": "^3.3",
"doctrine/dbal": "^3.4",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"caneara/snowflake": "^2.0",
"doctrine/dbal": "^3.6",
"guzzlehttp/guzzle": "^7.5",
"laravel/framework": "^v10.0.0",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.7",
"mattkingshott/snowflake": "^2.0",
"nunomaduro/laravel-pot": "^0.2.0",
"spatie/laravel-route-attributes": "^1.15",
"spatie/laravel-route-attributes": "^1.18",
"symfony/clock": "^6.2@beta"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.12",
"behat/behat": "^3.11",
"brianium/paratest": "^6.6",
"behat/behat": "^3.12",
"brianium/paratest": "^7.0",
"driftingly/rector-laravel": "*",
"fakerphp/faker": "^1.9.1",
"infection/infection": "^0.26.15",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.11",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.14",
"laravel/pint": "^1.0",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"mortexa/laravel-arkitect": "^0.3.3",
"nunomaduro/collision": "^6.1",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.0",
"phparkitect/phparkitect": "^0.2.32",
"phpunit/phpunit": "^9.5.10",
"qossmic/deptrac-shim": "^0.24.0",
"phpunit/phpunit": "^10.0.0",
"qossmic/deptrac-shim": "*",
"rector/rector": "^0.14.6",
"spatie/laravel-ignition": "^1.0"
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -84,6 +84,6 @@
"infection/extension-installer": true
}
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true
}
Loading

0 comments on commit 8d353e7

Please sign in to comment.