Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Silex to Symfony4 #38

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/build/
/vendor/
/cache/*
/logs/*
silex.log
/config/parameters.yml
/.vagrant
node_modules/
web/css/*
web/img/*
web/js/*
/.phpunit.result.cache
/var/
!/var/.gitkeep

###> symfony/webpack-encore-bundle ###
/node_modules/
/web/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ENV?=dev

help: ## Show help
@echo
@echo "Usage: make [target]"
@echo
@printf "\033[1;93mAvailable targets:\033[0m\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo

install: vendor node_modules build-assets ## Install all project dependencies

build-assets: ## Build JS, CSS and images
node_modules/.bin/encore $(ENV)

vendor: composer.json composer.lock
composer install

node_modules: package.json
npm install

unit-tests: ## Run unit tests
vendor/bin/phpunit

lint:
bin/console lint:twig templates/

test: unit-tests lint

.PHONY: help install build-assets unit-tests lint test
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AmsterdamPHP - Meetup.com Raffler

This application enables us to raffle off stuff to our meetup attendees. It uses the Meetup.com API to get all check ins, and then uses the Random.org API to randomly select winners.
This application enables us to raffle off stuff to our meetup attendees. It uses the Meetup.com API to get all check ins, and then randomly selects winners.

## Installation

Expand All @@ -9,50 +9,49 @@ This application enables us to raffle off stuff to our meetup attendees. It uses
Ensure that [VirtualBox](https://www.virtualbox.org), [Vagrant](http://www.vagrantup.com), and [Ansible](http://www.ansible.com) are installed.

1. `git clone [email protected]:AmsterdamPHP/meetup-raffle-machine.git --recursive`
2. run `vagrant up`
3. create config/parameters.yml (get your API key from [meetup.com](https://secure.meetup.com/meetup_api/key/))
1. run `vagrant up`
1. create `config/parameters.yml` (get your API key from [meetup.com](https://secure.meetup.com/meetup_api/key/))

```
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
parameters:
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
secret: SomeRandomSecretToSeedSymfony
redis_dsn: redis://localhost
```
1. Add the following to your hosts file: `10.10.10.10 raffler.local`

All done! Now you can access the application at [http://app.local/](http://app.local/).
All done! Now you can access the application at [http://raffler.local/](http://raffler.local/).

### Install directly onto your host machine.

1. Get code
2. Give permissions
1. Give permissions

```
sudo chmod -Rf +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" cache logs
sudo chmod -Rf +a "<apache user> allow delete,write,append,file_inherit,directory_inherit" cache logs
```

3. Install Dependencies
1. Install Dependencies

```
composer install
npm install
make install
```

4. Compile assets

```
./node_modules/.bin/gulp
```

5. Create config/parameters.yml
1. Create config/parameters.yml

```
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
parameters:
meetup_group: amsterdamphp
meetup_api_key: YOUR_MEETUP_API_KEY
secret: SomeRandomSecretToSeedSymfony
redis_dsn: redis://localhost
```

## How to use it

1. Open the app index page to be presented with a list of meetups.
2. Click on a meetup.
3. Press [space] or [page down] to start raffles.
1. Click on a meetup.
1. Press [space] or [page down] to start raffles.

The page down key allows us to use most presentation remotes as well.
57 changes: 28 additions & 29 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
# vagrant init ubuntu/trusty64
# vagrant init ubuntu/xenial64

Vagrant.configure("2") do |config|
config.vm.box = "trusty64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.box = "ubuntu/xenial64"

config.vm.network :private_network, ip: "10.10.10.10"
config.vm.hostname = "app.local"

config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 1024]
v.customize ["modifyvm", :id, "--name", "Meetup Raffle Machine"]
v.customize ["modifyvm", :id, "--name", "AmsterdamPHP Raffler"]
end

config.vm.provider :libvirt do |domain|
domain.memory = 1024
config.vm.provision "shell" do |s|
s.inline = "sudo apt-get update && sudo apt-get install -y python"
end

if (/linux/ =~ RUBY_PLATFORM) != nil
config.vm.synced_folder "./", "/vagrant", id: "vagrant-root", nfs: true, :linux__nfs_options => ['rw','no_subtree_check','all_squash','async']
else
config.vm.synced_folder "./", "/vagrant", id: "vagrant-root", :nfs => true
end

if not Vagrant.has_plugin?("vagrant-hostmanager")
if system "vagrant plugin install vagrant-hostmanager"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Aborting due to plugin installation failure."
end
end

config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.include_offline = true

config.vm.provision "ansible" do |ansible|
ansible.playbook = "ansible/provision.yml"
ansible.extra_vars = {
hostname: "dev",
hostname: "raffler",
dbuser: "root",
dbpasswd: "password",
databases: ["development"],
sites: [
{
hostname: "app.local",
hostname: "raffler.local",
document_root: "/vagrant/web"
}
],
php_configs: [
],
install_postgresql: "no",
postgresql_version: "9.5",
postgresql_user: "root",
postgresql_passwd: "password",
postgresql_databases: ["development"],
install_gems: [],
install_db: "no",
install_ohmyzsh: "yes",
install_web: "yes",
install_mailcatcher: "no",
install_hhvm: "no",
install_beanstalkd: "no",
install_redis: "yes",
install_javascript_build_system: "yes"
install_javascript_build_system: "yes",
install_r: "no",
install_rabbit_mq: "no",
r_packages: [],
enable_swap: "yes",
swap_size_in_mb: "1024",
install_eventstore: "no",
eventstore_version: "3.0.1",
eventstore_bind_ip: "10.10.10.10",
eventstore_http_prefix: "http://app.local:2113/"
}
end

config.vm.provision "shell", path: "post-install.sh"
config.vm.provision "shell" do |s|
s.inline = "cd /vagrant; make install"
end
end
2 changes: 1 addition & 1 deletion ansible
3 changes: 3 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: lightgray;
}
14 changes: 14 additions & 0 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/

// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.css');

// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
// const $ = require('jquery');

console.log('Hello Webpack Encore! Edit me in assets/js/app.js');
42 changes: 42 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
Empty file removed cache/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
machine:
php:
version: 7.0.4
version: 7.2

dependencies:
override:
- composer install --dev --no-progress --no-interaction --prefer-dist
- npm install
- ./node_modules/.bin/gulp
- node_modules/.bin/encore prod

post:
- mkdir -p $CIRCLE_TEST_REPORTS/phpunit

test:
override:
- ./vendor/bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml
- make test

deployment:
production:
Expand Down
Loading