Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maintenance] Upgrade Recipes & Refine Project Structure #1028

Merged
merged 14 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ indent_size = 4
indent_style = space
indent_size = 2

[phpspec.yml{,.dist}]
indent_style = space
indent_size = 4

[phpstan.neon]
[phpstan.dist.neon]
indent_style = space
indent_size = 4

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,12 @@ jobs:

-
name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/
run: vendor/bin/phpstan analyse -c phpstan.dist.neon -l max src/

-
name: Validate database schema
run: bin/console doctrine:schema:validate

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

-
name: Run PHPUnit
run: vendor/bin/phpunit --colors=always
Expand Down
15 changes: 12 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
/etc/build/*
!/etc/build/.gitignore

/behat.yml
/phpspec.yml

/drivers/

/docker-compose.override.yaml
Expand Down Expand Up @@ -52,3 +49,15 @@
/yarn.lock
/package-lock.json
###< symfony/webpack-encore-bundle ###

###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###

###> friends-of-behat/symfony-extension ###
/behat.yml
###< friends-of-behat/symfony-extension ###

###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Enjoy being an eCommerce Developer again!

Powerful REST API allows for easy integrations and creating unique customer experience on any device.

We're using full-stack Behavior-Driven-Development, with [phpspec](http://phpspec.net) and [Behat](http://behat.org)
We're using full-stack Behavior-Driven-Development, with [Behat](http://behat.org)

## Documentation

Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"require-dev": {
"behat/behat": "^3.7",
"behat/mink-selenium2-driver": "^1.4",
"dbrekelmans/bdi": "^1.1",
"dbrekelmans/bdi": "^1.3",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -47,13 +47,11 @@
"friends-of-behat/variadic-extension": "^1.3",
"lchrusciel/api-test-case": "^5.0",
"nyholm/psr7": "^1.8",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8.4",
"phpstan/phpstan-doctrine": "^1.3.2",
"phpstan/phpstan-webmozart-assert": "^1.1",
"phpunit/phpunit": "^10.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.0",
"sylius-labs/suite-tags-extension": "^0.2",
Expand Down
14 changes: 6 additions & 8 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<?php

declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) {
$_SERVER += $env;
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');

return;
} else {
// load all the .env files
(new Dotenv(true))->loadEnv(dirname(__DIR__).'/.env');
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
1 change: 1 addition & 0 deletions config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ api_platform:
paths:
- '%kernel.project_dir%/config/api_platform'
- '%kernel.project_dir%/src/Entity'
- '%kernel.project_dir%/src/ApiResource'
patch_formats:
json: ['application/merge-patch+json']
swagger:
Expand Down
19 changes: 19 additions & 0 deletions config/packages/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
5 changes: 5 additions & 0 deletions config/packages/debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
when@dev:
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"
5 changes: 4 additions & 1 deletion config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ doctrine_migrations:
table_storage:
table_name: sylius_migrations
migrations_paths:
'App\Migrations': "%kernel.project_dir%/src/Migrations"
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'App': '%kernel.project_dir%/migrations'
enable_profiler: false
22 changes: 22 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed

transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'

routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async

# when@test:
# framework:
# messenger:
# transports:
# # replace with your transport name here (e.g., my_transport: 'in-memory://')
# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
# async: 'in-memory://'
61 changes: 61 additions & 0 deletions config/packages/monolog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists

when@dev:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]

when@test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
channels: [deprecation]
path: php://stderr
formatter: monolog.formatter.json
12 changes: 12 additions & 0 deletions config/packages/nelmio_alice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
when@dev: &dev
nelmio_alice:
functions_blacklist:
- 'current'
- 'shuffle'
- 'date'
- 'time'
- 'file'
- 'md5'
- 'sha1'

when@test: *dev
11 changes: 11 additions & 0 deletions config/packages/nyholm_psr7.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be for removing this config as nyholm is a dev dependency and probably we should not force to have it in the config in the end application

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
# Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories)
Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory'
Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory'

nyholm.psr7.psr17_factory:
class: Nyholm\Psr7\Factory\Psr17Factory
4 changes: 4 additions & 0 deletions config/packages/payum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#payum:
# gateways:
# offline:
# factory: offline
15 changes: 15 additions & 0 deletions config/packages/sylius_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# @see https://github.com/Sylius/SyliusResourceBundle/blob/master/docs/index.md
sylius_resource:
# Override default settings
#settings:

# Configure the mapping for your resources
mapping:
paths:
- '%kernel.project_dir%/src/Entity'

# Configure your resources
resources:
#app.book:
#classes:
#model: App\Entity\Book
4 changes: 4 additions & 0 deletions config/routes/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
api_platform:
resource: .
type: api_platform
prefix: /
4 changes: 4 additions & 0 deletions config/routes/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error
3 changes: 3 additions & 0 deletions config/routes/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_security_logout:
resource: security.route_loader.logout
type: service
7 changes: 7 additions & 0 deletions config/routes/sylius_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sylius_crud_routes:
resource: 'sylius.routing.loader.crud_routes_attributes'
type: service

sylius_routes:
resource: 'sylius.routing.loader.routes_attributes'
type: service
8 changes: 8 additions & 0 deletions config/routes/web_profiler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt

web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
File renamed without changes.
6 changes: 0 additions & 6 deletions phpspec.yaml.dist

This file was deleted.

8 changes: 8 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 9
paths:
- bin/
- config/
- public/
- src/
- tests/
3 changes: 0 additions & 3 deletions phpstan.neon

This file was deleted.

24 changes: 20 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php">
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<php>
<ini name="error_reporting" value="-1" />

<!-- ###+ symfony/framework-bundle ### -->
<env name="APP_DEBUG" value="0"/>
<env name="APP_ENV" value="test"/>
<env name="SHELL_VERBOSITY" value="-1" />
<!-- ###- symfony/framework-bundle ### -->

<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="ESCAPE_JSON" value="true" />

<server name="KERNEL_CLASS" value="App\Kernel" />
</php>
</phpunit>
Empty file added src/ApiResource/.gitignore
Empty file.
4 changes: 0 additions & 4 deletions src/Entity/Addressing/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Address as BaseAddress;

/**
* @ORM\Entity
* @ORM\Table(name="sylius_address")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_address')]
class Address extends BaseAddress
Expand Down
Loading
Loading