Skip to content

Commit 29e5543

Browse files
committed
Initial Commit
0 parents  commit 29e5543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7384
-0
lines changed

.env.dist

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is a "template" of which env vars need to be defined for your application
2+
# Copy this file to .env file for development, create environment variables when deploying to production
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=dev
7+
APP_SECRET=47e8db9fb7a00e7a59fd6cec61d152fd
8+
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9+
#TRUSTED_HOSTS=localhost,example.com
10+
###< symfony/framework-bundle ###
11+
12+
###> doctrine/doctrine-bundle ###
13+
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
14+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
15+
# Configure your db driver and server_version in config/packages/doctrine.yaml
16+
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name
17+
###< doctrine/doctrine-bundle ###
18+
19+
###> symfony/swiftmailer-bundle ###
20+
# For Gmail as a transport, use: "gmail://username:password@localhost"
21+
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
22+
# Delivery is disabled by default via "null://localhost"
23+
MAILER_URL=null://localhost
24+
###< symfony/swiftmailer-bundle ###

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
###> symfony/framework-bundle ###
3+
.env
4+
/public/bundles/
5+
/var/
6+
/vendor/
7+
###< symfony/framework-bundle ###
8+
9+
###> symfony/web-server-bundle ###
10+
.web-server-pid
11+
###< symfony/web-server-bundle ###
12+
13+
###> symfony/phpunit-bridge ###
14+
.phpunit
15+
/phpunit.xml
16+
###< symfony/phpunit-bridge ###
17+
18+
.idea

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: php
2+
before_script:
3+
- composer self-update
4+
- composer install
5+
php:
6+
- 7.0
7+
- 7.1
8+
script:
9+
- phpunit --coverage-clover=coverage.clover
10+
after_script:
11+
- wget https://scrutinizer-ci.com/ocular.phar
12+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
13+
matrix:
14+
fast_finish: true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Matthew Javelet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Syfony Flex API Starter
2+
3+
This in an API starter kit built with Symfony flex and FOS bundles that help achieve a full fledged rest API with an OAuth 2.0 server.
4+
5+
## Getting Started
6+
7+
Simply clone this repo, run `composer install`, modify your .env file and run `php bin/console server:run` to view the live development server!
8+
9+
## What does it include?
10+
11+
* [FOSRESTBundle](https://github.com/FriendsOfSymfony/FOSRestBundle)
12+
* [FOSOAuthServerBundle](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle)
13+
* [FOSUserBundle](https://github.com/FriendsOfSymfony/FOSUserBundle)
14+
* [NelmioAPIDocBundle](https://github.com/nelmio/NelmioApiDocBundle)
15+
* [JSMSerializerBundle](https://github.com/schmittjoh/JMSSerializerBundle)
16+
17+
18+
## Help me set up?
19+
20+
Sure. Getting setup with the available console commands can help make your life much easier during this initial process.
21+
22+
First things you may want to do are to setup a user and oauth client to make requests with.
23+
24+
```text
25+
php bin/console fos:user:create
26+
```
27+
Followed by
28+
```text
29+
php bin/consle api:client:create
30+
```
31+
32+
With your newly created client, you can authenticate with the OAuth server and user, so long as you at least had chosen the password grant type, otherwise authorize with the client_credentials spec.
33+
34+
```text
35+
curl -X POST \
36+
http://localhost:8000/oauth/v2/token \
37+
-H 'accept: application/json' \
38+
-H 'content-type: application/x-www-form-urlencoded' \
39+
-d 'client_id=%client_id%&client_secret=%client_secret%&grant_type=client_credentials'
40+
```
41+
42+
And you'll get your token!
43+
44+
```text
45+
{
46+
"access_token": "YmZkNmNmN2I1Y2E3MGFhZTIzMjE0N2UyMGYyZTdjZTBiYzk4NzE4M2ExZTY3YThjODhkYzIxNDBkMjNiN2UzZg",
47+
"expires_in": 3600,
48+
"token_type": "bearer",
49+
"scope": "user"
50+
}
51+
```

bin/console

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\Debug\Debug;
8+
use Symfony\Component\Dotenv\Dotenv;
9+
10+
set_time_limit(0);
11+
12+
require __DIR__.'/../vendor/autoload.php';
13+
14+
if (!class_exists(Application::class)) {
15+
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
16+
}
17+
18+
if (!isset($_SERVER['APP_ENV'])) {
19+
if (!class_exists(Dotenv::class)) {
20+
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
21+
}
22+
(new Dotenv())->load(__DIR__.'/../.env');
23+
}
24+
25+
$input = new ArgvInput();
26+
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
27+
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
28+
29+
if ($debug) {
30+
umask(0000);
31+
32+
if (class_exists(Debug::class)) {
33+
Debug::enable();
34+
}
35+
}
36+
37+
$kernel = new Kernel($env, $debug);
38+
$application = new Application($kernel);
39+
$application->run($input);

bin/phpunit

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
5+
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
6+
exit(1);
7+
}
8+
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
9+
putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
10+
}
11+
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
12+
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
13+
}
14+
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
15+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
16+
}
17+
18+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

composer.json

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"type": "project",
3+
"license": "MIT",
4+
"authors": [{
5+
"name": "Matthew Javelet",
6+
"email": "[email protected]"
7+
}],
8+
"minimum-stability": "dev",
9+
"require": {
10+
"php": "^7.1.3",
11+
"ext-iconv": "*",
12+
"friendsofsymfony/oauth-server-bundle": "dev-master",
13+
"friendsofsymfony/rest-bundle": "^2.3",
14+
"friendsofsymfony/user-bundle": "2.1.x-dev",
15+
"jms/serializer-bundle": "^2.3@dev",
16+
"nelmio/api-doc-bundle": "^3.1@dev",
17+
"sensio/framework-extra-bundle": "^5.1@dev",
18+
"symfony/asset": "^4.0",
19+
"symfony/console": "^4.0",
20+
"symfony/flex": "^1.0",
21+
"symfony/form": "^4.0",
22+
"symfony/framework-bundle": "^4.0",
23+
"symfony/lts": "^4@dev",
24+
"symfony/orm-pack": "^1.0",
25+
"symfony/security-bundle": "^4.0",
26+
"symfony/security-csrf": "^4.0",
27+
"symfony/swiftmailer-bundle": "^3.1",
28+
"symfony/yaml": "^4.0"
29+
},
30+
"require-dev": {
31+
"symfony/browser-kit": "^4.0",
32+
"symfony/dotenv": "^4.0",
33+
"symfony/maker-bundle": "^1.0",
34+
"symfony/phpunit-bridge": "^4.0",
35+
"symfony/profiler-pack": "^1.0",
36+
"symfony/web-server-bundle": "^4.0"
37+
},
38+
"config": {
39+
"preferred-install": {
40+
"*": "dist"
41+
},
42+
"sort-packages": true
43+
},
44+
"autoload": {
45+
"psr-4": {
46+
"App\\": "src/"
47+
}
48+
},
49+
"autoload-dev": {
50+
"psr-4": {
51+
"App\\Tests\\": "tests/"
52+
}
53+
},
54+
"replace": {
55+
"symfony/polyfill-iconv": "*",
56+
"symfony/polyfill-php71": "*",
57+
"symfony/polyfill-php70": "*",
58+
"symfony/polyfill-php56": "*"
59+
},
60+
"scripts": {
61+
"auto-scripts": {
62+
"cache:clear": "symfony-cmd",
63+
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
64+
},
65+
"post-install-cmd": [
66+
"@auto-scripts"
67+
],
68+
"post-update-cmd": [
69+
"@auto-scripts"
70+
]
71+
},
72+
"conflict": {
73+
"symfony/symfony": "*"
74+
},
75+
"extra": {
76+
"symfony": {
77+
"id": "01C3Y2CEKAR12D535NZQ143HAQ",
78+
"allow-contrib": false
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)