Skip to content

Commit ace6feb

Browse files
committed
update
1 parent b9b61ac commit ace6feb

28 files changed

+1382
-60
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@ on:
33
- pull_request
44
- push
55
jobs:
6+
psalm:
7+
name: Psalm
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Install PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: 8.1
16+
coverage: none
17+
- name: Composer install
18+
run: composer install --no-interaction --no-ansi --no-progress
19+
- name: Run Psalm
20+
run: vendor/bin/psalm --no-progress --shepherd --show-info=false --stats
621
phpunit:
722
name: "PHPUnit (PHP: ${{ matrix.php-versions }})"
823
runs-on: ubuntu-latest
924
strategy:
1025
matrix:
1126
php-versions:
12-
- 8.0
13-
- 8.1
27+
- 8.1
28+
- 8.2
1429
steps:
1530
- name: Checkout
1631
uses: actions/checkout@v2

bin/psx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* PSX is a open source PHP framework to develop RESTful APIs.
55
* For the current version and informations visit <http://phpsx.org>
66
*
7-
* Copyright 2010-2016 Christoph Kappestein <k42b3.x@gmail.com>
7+
* Copyright 2010-2023 Christoph Kappestein <christoph.kappestein@gmail.com>
88
*
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -41,9 +41,9 @@ if (!empty($autoloadFile)) {
4141
if (is_file($containerFile)) {
4242
$container = require_once($containerFile);
4343

44-
PSX\Framework\Bootstrap::setupEnvironment($container->get('config'));
44+
PSX\Framework\Bootstrap::setupEnvironment($container->getParameter('psx_debug'));
4545

46-
$container->get('console')->run();
46+
$container->get(\Symfony\Component\Console\Application::class)->run();
4747
} else {
4848
die('Could not find container at: ' . $containerFile);
4949
}

composer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
],
1414
"require": {
1515
"php": ">=8.0",
16-
"psx/framework": "^6.0"
16+
"psx/framework": "^7.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^8.0",
20-
"guzzlehttp/guzzle": "^6.3"
19+
"phpunit/phpunit": "^9.0",
20+
"guzzlehttp/guzzle": "^7.0",
21+
"vimeo/psalm": "^5.0"
2122
},
22-
"bin": ["bin/psx"],
23-
"autoload-dev": {
23+
"autoload": {
2424
"psr-4": {
25-
"PSX\\Framework\\App\\": "vendor/psx/framework/app/"
25+
"App\\": "src/"
2626
}
2727
},
28-
"minimum-stability": "RC"
28+
"autoload-dev": {
29+
"psr-4": {
30+
"App\\Tests\\": "tests/"
31+
}
32+
}
2933
}

container.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?php
22

3-
/*
4-
This file returns the global DI container for the application. The DI container
5-
must be compatible with the symfony DI container interface. If you want load an
6-
different configuration depending on the environment you can change the
7-
"config.file" parameter.
8-
*/
9-
10-
$container = new \PSX\Framework\App\Dependency\Container();
11-
$container->setParameter('config.file', __DIR__ . '/configuration.php');
12-
13-
return $container;
3+
return \PSX\Framework\Dependency\ContainerBuilder::build(
4+
__DIR__,
5+
getenv('PSX_ENV') !== 'prod',
6+
__DIR__ . '/vendor/psx/framework/resources/container.php',
7+
__DIR__ . '/resources/container.php',
8+
);

phpunit.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="tests/bootstrap.php" backupGlobals="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
</coverage>
38
<testsuites>
49
<testsuite name="PSX Test Suite">
5-
<directory>./vendor/psx/framework/app/Test</directory>
10+
<directory>./tests</directory>
611
</testsuite>
712
</testsuites>
8-
<filter>
9-
<whitelist>
10-
<directory suffix=".php">./vendor/psx/*/src</directory>
11-
</whitelist>
12-
</filter>
1313
<php>
14-
<!-- <env name="DB" value="sqlite" /> -->
14+
<ini name="date.timezone" value="UTC"/>
1515
</php>
1616
</phpunit>

psalm.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
</psalm>

public/index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
$container = require_once(__DIR__ . '/../container.php');
2424

25-
$engine = null;
26-
$environment = \PSX\Framework\Environment\Environment::fromContainer($container, $engine);
25+
$engine = new \PSX\Engine\WebServer\Engine($container->getParameter('psx_url'));
26+
$dispatcher = $container->get(\PSX\Engine\DispatchInterface::class);
27+
$environment = new \PSX\Framework\Environment\Environment($dispatcher, $engine, getenv('PSX_ENV') !== 'prod');
2728

2829
return $environment->serve();

resources/container.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use PSX\Framework\Controller\ControllerInterface;
4+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
5+
6+
return static function (ContainerConfigurator $container) {
7+
$services = $container->services();
8+
$services->defaults()
9+
->autowire()
10+
->autoconfigure();
11+
12+
$services
13+
->instanceof(ControllerInterface::class)
14+
->tag('psx.controller');
15+
16+
$services->load('App\\Controller\\', __DIR__ . '/../src/Controller')
17+
->public();
18+
19+
$services->load('App\\Service\\', __DIR__ . '/../src/Service')
20+
->public();
21+
22+
};

resources/typeschema.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"definitions": {
3+
"Welcome": {
4+
"type": "object",
5+
"properties": {
6+
"message": {
7+
"type": "string"
8+
},
9+
"url": {
10+
"type": "string"
11+
},
12+
"version": {
13+
"type": "string"
14+
}
15+
}
16+
},
17+
"Message": {
18+
"type": "object",
19+
"properties": {
20+
"success": {
21+
"type": "boolean"
22+
},
23+
"message": {
24+
"type": "string"
25+
},
26+
"id": {
27+
"type": "integer"
28+
}
29+
}
30+
},
31+
"Collection": {
32+
"type": "object",
33+
"properties": {
34+
"totalResults": {
35+
"type": "integer"
36+
},
37+
"startIndex": {
38+
"type": "integer"
39+
},
40+
"itemsPerPage": {
41+
"type": "integer"
42+
},
43+
"entry": {
44+
"type": "array",
45+
"items": {
46+
"$generic": "T"
47+
}
48+
}
49+
}
50+
},
51+
"Population_Collection": {
52+
"$ref": "Collection",
53+
"$template": {
54+
"T": "Population"
55+
}
56+
},
57+
"Population": {
58+
"type": "object",
59+
"properties": {
60+
"id": {
61+
"type": "integer"
62+
},
63+
"place": {
64+
"type": "integer"
65+
},
66+
"region": {
67+
"type": "string"
68+
},
69+
"population": {
70+
"type": "integer"
71+
},
72+
"users": {
73+
"type": "integer"
74+
},
75+
"worldUsers": {
76+
"type": "number"
77+
},
78+
"insertDate": {
79+
"type": "string",
80+
"format": "date-time"
81+
}
82+
}
83+
}
84+
}
85+
}

routes.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)