Skip to content
Snippets Groups Projects
Commit 869ed512 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Add a basic project

parent db630feb
Branches
Tags
No related merge requests found
/vendor
/var
/.php_cs
/.idea
/*.cache
composer.lock
\ No newline at end of file
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
;
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PHP73Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => false,
'strict_comparison' => true,
'strict_param' => true,
'declare_strict_types' => true,
])
->setRiskyAllowed(true)
->setFinder($finder)
;
\ No newline at end of file
# starter-bundle
# DBP API Starter Bundle
This Symfony bundle can be used as a template for creating new bundles for the
DBP API project.
When including this bundle into your DBP API server it will gain the following
features:
* TODO
* TODO
* ...
* profit
## Integration into the API Server
TODO: add to composer, create configuration, note how to see if it works
## Development & Testing
* Install dependencies: `composer install`
* Run tests: `composer test`
* Run linters: `composer run lint`
* Run cs-fixed: `composer run cs-fix`
\ No newline at end of file
{
"name": "dbp/api-starter-bundle",
"type": "symfony-bundle",
"license": "AGPL-3.0-or-later",
"require": {
"php": "^7.3",
"api-platform/core": "^2.4",
"symfony/framework-bundle": "^4.1.12",
"dbp/api-core-bundle": "@dev"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.12.33",
"phpstan/phpstan-phpunit": "^0.12.13",
"symfony/phpunit-bridge": "^4.4",
"vimeo/psalm": "^3.12"
},
"repositories": [
{
"type": "path",
"url": "../../API/bundles/api-core-bundle"
}
],
"autoload": {
"psr-4": {
"DBP\\API\\StarterBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DBP\\API\\StarterBundle\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true,
"platform": {
"php": "7.3"
}
},
"scripts": {
"test": [
"@php vendor/bin/simple-phpunit"
],
"phpstan": [
"@php vendor/bin/simple-phpunit --atleast-version 0",
"@php vendor/bin/phpstan analyze --ansi"
],
"psalm": [
"@php vendor/bin/simple-phpunit --atleast-version 0",
"@php vendor/bin/psalm"
],
"lint": [
"@composer run cs",
"@composer run phpstan",
"@composer run psalm"
],
"cs-fix": [
"@php vendor/bin/php-cs-fixer --ansi fix"
],
"cs": [
"@php vendor/bin/php-cs-fixer --ansi fix --dry-run --diff --diff-format=udiff"
]
}
}
\ No newline at end of file
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
inferPrivatePropertyTypeFromConstructor: true
level: 3
paths:
- src
- tests
bootstrapFiles:
- vendor/bin/.phpunit/phpunit-8-0/vendor/autoload.php
excludes_analyse:
- tests/bootstrap.php
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="8" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
<directory>tests</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="5"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
<?php
declare(strict_types=1);
namespace DBP\API\StarterBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TestCommand extends Command
{
public function __construct()
{
parent::__construct();
}
protected function configure()
{
$this->addArgument('argument', InputArgument::REQUIRED, 'Example.');
$this->setDescription('Hey there!');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$argument = $input->getArgument('argument');
$output->write($argument);
return 0;
}
}
<?php
declare(strict_types=1);
namespace DBP\API\StarterBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class DbpStarterBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
}
}
<?php
declare(strict_types=1);
namespace DBP\API\StarterBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class DbpStarterExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader(
$container,
new FileLocator(__DIR__.'/../Resources/config')
);
$loader->load('services.yaml');
}
}
services:
DBP\API\StarterBundle\Command\TestCommand:
autowire: true
autoconfigure: true
\ No newline at end of file
<?php
declare(strict_types=1);
namespace DBP\API\StarterBundle\Service;
class ExternalApi
{
public function __construct()
{
}
}
<?php
declare(strict_types=1);
namespace DBP\API\StarterBundle\Tests\Service;
use DBP\API\StarterBundle\Service\ExternalApi;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ExternalApiTest extends WebTestCase
{
private $api;
protected function setUp(): void
{
$this->api = new ExternalApi();
}
public function test()
{
$this->assertTrue(true);
}
}
<?php
declare(strict_types=1);
require dirname(__DIR__).'/vendor/autoload.php';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment