mirror of
https://ghproxy.net/https://github.com/aspirepress/AspireCloud.git
synced 2025-10-04 23:20:41 +08:00
Updating Makefile and including a new coding standard.
This commit is contained in:
parent
085b17d65b
commit
1623cdcfc3
12 changed files with 1486 additions and 1166 deletions
56
Makefile
56
Makefile
|
@ -1,27 +1,65 @@
|
|||
.PHONY: *
|
||||
|
||||
# Set additional parameters for command
|
||||
OPTS=
|
||||
|
||||
unit:
|
||||
# Set DEBUG=1 to enable xdebug
|
||||
ifeq ($(origin DEBUG),undefined)
|
||||
XDEBUG :=
|
||||
PHPSTAN_XDEBUG :=
|
||||
else
|
||||
XDEBUG := XDEBUG_SESSION=1
|
||||
PHPSTAN_XDEBUG := --xdebug
|
||||
endif
|
||||
|
||||
list:
|
||||
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
|
||||
unit: ## Run unit tests
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpunit --testsuite=unit ${OPTS}"
|
||||
|
||||
functional:
|
||||
functional: ## Run functional tests
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpunit --testsuite=functional ${OPTS}"
|
||||
|
||||
test:
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpunit ${OPTS}"
|
||||
test: unit functional acceptance ## Run all tests
|
||||
|
||||
acceptance:
|
||||
acceptance: ## Run acceptance tests
|
||||
docker compose run --rm webapp bash -c "vendor/bin/behat -vvv ${OPTS}"
|
||||
|
||||
stan:
|
||||
quality: ## Run all quality checks
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpstan ${OPTS}"
|
||||
|
||||
assets:
|
||||
quality-baseline: ## Run all static analysis checks with baseline
|
||||
docker compose run --rm webapp vendor/bin/phpstan analyse -b baseline.neon $(PHPSTAN_XDEBUG) src tests
|
||||
|
||||
assets: ## Build assets
|
||||
docker compose run --rm node bash -c "npx mix"
|
||||
|
||||
assets-watch:
|
||||
assets-watch: ## Watch assets
|
||||
docker compose run --rm node bash -c "npx mix watch"
|
||||
|
||||
install-node:
|
||||
install-node: ## Install node dependencies
|
||||
docker compose run --rm node bash -c "npm install"
|
||||
|
||||
install-composer: ## Install composer dependencies
|
||||
docker compose run --rm webapp bash -c "composer install"
|
||||
|
||||
logs-%: ## View logs (follow mode) for the container where % is a service name (webapp, postgres, node, nginx, smtp, rabbitmq)
|
||||
docker compose logs -f $*
|
||||
|
||||
sh-webapp: # webapp is alpine, so we need to use sh, not sh
|
||||
docker compose exec webapp sh
|
||||
|
||||
sh-%: ## Execute shell for the container where % is a service name (webapp, postgres, node, nginx, smtp, rabbitmq)
|
||||
docker compose exec $* sh
|
||||
|
||||
clear-cache: ## Clear cache
|
||||
docker compose run --rm webapp rm -f data/cache/config-cache.php
|
||||
rm -rf public/build/
|
||||
|
||||
cs: ## Run code style checks
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpcs ${OPTS}"
|
||||
|
||||
cs-fix: ## Fix code style issues
|
||||
docker compose run --rm webapp bash -c "vendor/bin/phpcbf ${OPTS} && vendor/bin/phpcs ${OPTS}"
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"php": "^8.3",
|
||||
"composer/package-versions-deprecated": "^1.10.99",
|
||||
"laminas/laminas-coding-standard": "^2.5",
|
||||
"laminas/laminas-component-installer": "^3.2",
|
||||
"laminas/laminas-config-aggregator": "^1.6",
|
||||
"laminas/laminas-diactoros": "^2.7",
|
||||
|
@ -35,8 +36,7 @@
|
|||
"phpunit/phpunit": "^9.5.11",
|
||||
"roave/behat-psr11extension": "^2.2",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"slevomat/coding-standard": "^8.12",
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
"slevomat/coding-standard": "^7.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
2543
composer.lock
generated
2543
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -2,15 +2,17 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Monolog\Level;
|
||||
|
||||
return [
|
||||
/*
|
||||
* Logging Configuration
|
||||
*/
|
||||
'logging' => [
|
||||
'path' => './logs/',
|
||||
'path' => './logs/',
|
||||
'error' => [
|
||||
'file' => 'error.log',
|
||||
'level' => \Monolog\Level::Debug,
|
||||
'file' => 'error.log',
|
||||
'level' => Level::Debug,
|
||||
],
|
||||
],
|
||||
|
||||
|
@ -19,7 +21,7 @@ return [
|
|||
*/
|
||||
'templates' => [
|
||||
'extension' => 'php',
|
||||
'paths' => [
|
||||
'paths' => [
|
||||
'app' => './templates/app',
|
||||
],
|
||||
],
|
||||
|
|
|
@ -11,7 +11,7 @@ RUN docker-php-ext-install pdo \
|
|||
&& docker-php-ext-install pdo_pgsql \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-install intl \
|
||||
&& pecl install xdebug-3.2.1 \
|
||||
&& pecl install xdebug-3.3.0 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& docker-php-ext-enable pdo_pgsql
|
||||
|
||||
|
|
|
@ -21,6 +21,14 @@
|
|||
<!-- Include all rules from the PSR-12 Coding Standard -->
|
||||
<rule ref="PSR12"/>
|
||||
|
||||
<!-- Include all rules from the Laminas Coding Standard -->
|
||||
<rule ref="LaminasCodingStandard">
|
||||
<!-- Allow long lines -->
|
||||
<exclude name="Generic.Files.LineLength.TooLong" />
|
||||
<!-- Allow PHP standard functions to be called without importing -->
|
||||
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
|
||||
<exclude-pattern>src/ConfigProvider.*.php</exclude-pattern>
|
||||
</rule>
|
||||
|
|
|
@ -19,13 +19,13 @@ class ConfigProvider
|
|||
'delegators' => [
|
||||
ErrorHandler::class => [LoggingListenerDelegatorFactory::class],
|
||||
],
|
||||
'factories' => [
|
||||
'factories' => [
|
||||
TestPage::class => TestPageFactory::class,
|
||||
|
||||
// Logging Config
|
||||
'error' => LoggingFactory::class,
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Laminas\ServiceManager\ServiceManager;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
|
@ -12,11 +13,11 @@ class LoggingFactory
|
|||
{
|
||||
public function __invoke(ServiceManager $serviceManager, string $serviceName): Logger
|
||||
{
|
||||
$config = $serviceManager->get('config');
|
||||
$config = $serviceManager->get('config');
|
||||
$loggingInfo = $config['logging'];
|
||||
|
||||
if (!isset($loggingInfo[$serviceName])) {
|
||||
throw new \InvalidArgumentException('Unknown service name: ' . $serviceName);
|
||||
if (! isset($loggingInfo[$serviceName])) {
|
||||
throw new InvalidArgumentException('Unknown service name: ' . $serviceName);
|
||||
}
|
||||
|
||||
$logConfig = $loggingInfo[$serviceName];
|
||||
|
|
|
@ -7,10 +7,11 @@ namespace App;
|
|||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
class LoggingListener
|
||||
{
|
||||
const LOG_FORMAT = '%d [%s] %s: %s';
|
||||
private const LOG_FORMAT = '%d [%s] %s: %s';
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
|
@ -19,7 +20,7 @@ class LoggingListener
|
|||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function __invoke(\Throwable $error, ServerRequestInterface $request, ResponseInterface $response): void
|
||||
public function __invoke(Throwable $error, ServerRequestInterface $request, ResponseInterface $response): void
|
||||
{
|
||||
$this->logger->error(
|
||||
sprintf(
|
||||
|
@ -27,7 +28,7 @@ class LoggingListener
|
|||
$response->getStatusCode(),
|
||||
$request->getMethod(),
|
||||
(string) $request->getUri(),
|
||||
(string)$error
|
||||
(string) $error
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,5 +4,4 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Test\Acceptance;
|
||||
|
||||
$container = require 'config/container.php';
|
||||
return $container;
|
||||
return require 'config/container.php';
|
||||
|
|
|
@ -6,4 +6,4 @@ declare(strict_types=1);
|
|||
error_reporting(E_ALL);
|
||||
|
||||
// autoloader
|
||||
require(dirname(__DIR__) . '/vendor/autoload.php');
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
|
|
@ -10,6 +10,6 @@ class SampleFunctionalTest extends TestCase
|
|||
{
|
||||
public function testSubtraction(): void
|
||||
{
|
||||
$this->assertEquals(2, (4 - 2));
|
||||
$this->assertEquals(2, 4 - 2);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue