Skip to content

Commit

Permalink
Update to SF 3.3 and setup Symfony Flex
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrech committed Jun 18, 2017
1 parent 0299ac5 commit eea58f3
Show file tree
Hide file tree
Showing 34 changed files with 2,936 additions and 1,338 deletions.
13 changes: 13 additions & 0 deletions .env.dist
@@ -0,0 +1,13 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
REDIS_URL=

###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=98d174d70d76f824a2a601b715cbc53b
###< symfony/framework-bundle ###
11 changes: 8 additions & 3 deletions .gitignore
@@ -1,4 +1,9 @@
###> symfony/framework-bundle ###
.env
/var/
/vendor/
/var/*
/bin/php-cs-fixer
/bin/phpunit
/web/bundles/
###< symfony/framework-bundle ###
###> symfony/phpunit-bridge ###
/phpunit.xml
###< symfony/phpunit-bridge ###
1 change: 0 additions & 1 deletion .slugignore
@@ -1 +0,0 @@
web/index_dev.php
11 changes: 7 additions & 4 deletions .travis.yml
Expand Up @@ -8,9 +8,12 @@ cache:

matrix:
include:
- php: hhvm
- php: 5.6
- php: 7.0
- php: 7.1

env:
global:
- APP_ENV=test
- APP_DEBUG=0

install:
- composer --prefer-source update;
- composer install --prefer-dist;
34 changes: 34 additions & 0 deletions Makefile
@@ -0,0 +1,34 @@
ifndef APP_ENV
include .env
endif

###> symfony/framework-bundle ###
cache-clear:
@test -f bin/console && bin/console cache:clear --no-warmup || rm -rf var/cache/*
.PHONY: cache-clear

cache-warmup: cache-clear
@test -f bin/console && bin/console cache:warmup || echo "cannot warmup the cache (needs symfony/console)"
.PHONY: cache-warmup

CONSOLE=bin/console
sf_console:
@test -f $(CONSOLE) || printf "Run \033[32mcomposer require cli\033[39m to install the Symfony console.\n"
@exit

serve_as_sf: sf_console
@test -f $(CONSOLE) && $(CONSOLE)|grep server:start > /dev/null || ${MAKE} serve_as_php
@$(CONSOLE) server:start || exit 1

@printf "Quit the server with \033[32;49mbin/console server:stop.\033[39m\n"

serve_as_php:
@printf "\033[32;49mServer listening on http://127.0.0.1:8000\033[39m\n";
@printf "Quit the server with CTRL-C.\n"
@printf "Run \033[32mcomposer require symfony/web-server-bundle\033[39m for a better web server\n"
php -S 127.0.0.1:8000 -t web

serve:
@${MAKE} serve_as_sf
.PHONY: sf_console serve serve_as_sf serve_as_php
###< symfony/framework-bundle ###
45 changes: 26 additions & 19 deletions README.md
Expand Up @@ -4,12 +4,36 @@ Just go to https://slack-secret-santa.herokuapp.com/ and have fun.

Code source is under MIT License.

- This application is powered by Symfony 3 and its Micro Kernel;
- This application is powered by Symfony and its new Flex way to build app;
- Hosting is provided by Heroku;
- Session are stored in Heroku Redis servers;
- Built with ♥ by [@pyrech](https://github.com/pyrech) and [@damienalexandre](https://github.com/damienalexandre).

## Install, run and deploy
## Install and run locally

The app requires:

- a Redis server
- PHP 7.1+

Run the following command to launch the app locally:

`composer install`

We rely on some env variables to communicate with Slack API and Redis.
Check out the .env file and fill the correct values for the following variables:

- `SLACK_CLIENT_ID`: Application id from Slack;
- `SLACK_CLIENT_SECRET`: Application secret from Slack;
- `REDIS_URL`: The full redis connexion url (default `redis://localhost:6379`)

Then launch this command:

`make serve`

The application should now be running on http://127.0.0.1:8000.

## Deploy to Heroku

- Download and install the Heroku Toolbelt
- If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.
Expand All @@ -21,20 +45,3 @@ $ heroku git:remote -a slack-secret-santa
$ heroku plugins:install heroku-redis
$ git push heroku master
```

The app requires:

- a Redis server
- PHP 5.6+

As we rely on env variables, we cannot use `server:run`. Run:

cd web/
SLACK_CLIENT_SECRET=TOTO SLACK_CLIENT_ID=TOTO php -d variables_order=EGPCS -S 127.0.0.1:8000 ../etc/router.php
open http://127.0.0.1:8000/

Variables are:

- `SLACK_CLIENT_SECRET`: Application secret from Slack;
- `SLACK_CLIENT_ID`: Application id from Slack;
- `REDIS_URL`: The full redis connexion url (default `redis://localhost:6379`)
30 changes: 0 additions & 30 deletions bin/console

This file was deleted.

45 changes: 40 additions & 5 deletions composer.json
Expand Up @@ -18,16 +18,51 @@
}
},
"require": {
"php": "^7.1.3",
"bramdevries/oauth2-slack": "~0.1.0",
"cleentfaar/slack": "~0.17",
"symfony/symfony": "~3.1",
"predis/predis": "^1.0"
"predis/predis": "^1.0",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^3.3",
"symfony/twig-bundle": "^3.3",
"symfony/yaml": "^3.3",
"ircmaxell/random-lib": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
"friendsofphp/php-cs-fixer": "^1.9.3"
"friendsofphp/php-cs-fixer": "^1.9.3",
"phpunit/phpunit": "^6.2",
"symfony/browser-kit": "^3.3",
"symfony/css-selector": "^3.3",
"symfony/dotenv": "^3.3",
"symfony/phpunit-bridge": "^3.3",
"symfony/profiler-pack": "^1.0"
},
"config": {
"bin-dir": "bin"
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"scripts": {
"auto-scripts": {
"make cache-warmup": "script"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*",
"symfony/twig-bundle": "<3.3",
"symfony/debug": "<3.3"
},
"extra": {
"symfony": {
"id": "01BJXX8ZDDPMDF82T76S0FA56S",
"allow-contrib": false
}
}
}

0 comments on commit eea58f3

Please sign in to comment.