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

Ready for review: Migration to Symfony 3 #37

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8e92059
Added base installation of symfony 3 with sqlite
Feb 17, 2017
5d5c64b
Renamed Controller
Feb 17, 2017
701bbc7
Renamed test
Feb 17, 2017
8d53664
Implemented basic templating and good fallback for current API
Feb 17, 2017
b87dea6
Added entry entity and updated template
Feb 17, 2017
0a57dd8
Add .editorconfig for RobLoach
Feb 17, 2017
803ca23
Deleted unused assets
Feb 17, 2017
7af02af
Fixed .editorconfig
Feb 17, 2017
d87cabe
Fixed dependencies
Feb 20, 2017
a0e7e3d
Raised PHP-Version to at least 7.0
Feb 20, 2017
2596fe1
Added tests for Entry entity
Feb 20, 2017
bd07f6e
Removed php 7.1 feature
Feb 20, 2017
3305156
Fixed website for bigger and smaller screens
Feb 20, 2017
eec5a47
Remove a lot of php7 features and validate entity with assertions
Feb 20, 2017
98185b9
Add APIs
Feb 21, 2017
9f6edb8
Merge
Feb 21, 2017
d9bd11a
Remove PHP 5 support
RobLoach Feb 21, 2017
4cf4008
Merge pull request #1 from libretro/php-5
Feb 21, 2017
f21b84c
Add empty directory for tests to run.
Feb 22, 2017
575759d
Add more tests
Feb 22, 2017
5a8b6a3
Update .travis.yml
Feb 22, 2017
3f53e7f
Update .travis.yml
Feb 22, 2017
4a108e4
Update README.md
Feb 22, 2017
a0f0bdc
Added rest of API and extracted it to another controller
Feb 22, 2017
382cc2e
Merge branch 'master' of https://github.com/CoalaJoe/libretro-netplay…
Feb 22, 2017
5b46d24
Fixed embarassing typo
Feb 22, 2017
cbec5dc
Updated composer.json and added missing information
Feb 23, 2017
866afb0
Removed php7 features
Feb 23, 2017
beebc14
Add php5.6 testing to travis
Feb 23, 2017
1febc0d
Downgraded dependencies to php5.6
Feb 23, 2017
91c99b1
Merged
Feb 23, 2017
b1f0b55
Update README.md
Feb 23, 2017
d101bca
Fixed dependency issue
Feb 23, 2017
cf8dd3f
Fixed dependency issue
Feb 23, 2017
39dfcfc
Fixed #3: Add haspassword and port to the get parameters and validate…
Feb 24, 2017
0d3d789
Add travis to README.md
Feb 25, 2017
6da684e
Added Command for cleaning up old entries
Feb 27, 2017
eec418e
Add documentation to automating the cleanup process
Feb 27, 2017
5df367e
Merge branch 'master' of https://github.com/CoalaJoe/libretro-netplay…
Feb 27, 2017
55fc959
Fixed documentation
Feb 27, 2017
983ca53
Fixed documentation
Feb 27, 2017
17ef019
Fixed typo
Feb 27, 2017
b3facbc
Add phpstorm feature in symfony
Feb 27, 2017
9c64510
Add documentation for deletable files
Feb 27, 2017
0ae7c00
Refix typo
Feb 27, 2017
fb234f0
Refix typo
Feb 27, 2017
a3a04c4
Merge branch 'master' of https://github.com/CoalaJoe/libretro-netplay…
Feb 27, 2017
43ad0de
Add lifecycle callbacks to entries and created a eventlistener for li…
Feb 28, 2017
f309242
Added missing property in parameters.yml
Feb 28, 2017
e0843b2
Fixed test and use seperate db for tests
Mar 1, 2017
75a057e
Add tests for eventlistener
Mar 1, 2017
68ce106
Merge remote-tracking branch 'upstream/master'
Mar 1, 2017
b09bc1c
Removed SwiftMailer and numerous configurations
Mar 1, 2017
64cd73c
Remove weird file
Mar 1, 2017
ec02cd2
Improved documentation for more performance
Mar 1, 2017
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ insert_final_newline = true

[*.php]
indent_style = space
indent_size = 4
indent_size = 4
19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/app/config/parameters.yml
/build/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
!var/data
/vendor/
/web/bundles/
*.sqlite
vendor
composer.lock
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
language: php

php:
- '5.6'
- '7.0'
- '7.1'

cache:
directories:
- $HOME/.composer/cache/files

env:
- SYMFONY_VERSION="3.2.*" DB=mysql

before-install:
- composer self-update

install:
- composer install
- cp app/config/parameters.yml.dist app/config/parameters.yml
- php bin/console doctrine:database:create --env=test
- php bin/console doctrine:schema:create --env=test

script:
- composer test
- phpunit

cache:
directories:
- vendor
- $HOME/.composer

notifications:
email:
on_success: never
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
# libretro-netplay-registry
libretro-netplay-registry
=========================

Stores a netplay registry for libretro.

## Usage
# Requirements

- Retrieve all entries in registry.lpl by visiting index.php
- Add an entry by requesting index.php?username=<user>&ip=<ip>&corename=<corename>&coreversion=<coreversion>&gamename=<gamename>&gamecrc=<gamecrc>
* PHP 7 or higher
* [Composer](https://getcomposer.org/download/)
* And the requirements that are checked with: `php bin/symfony_requirements`

## Install
# Installation

1. Check out the git repository
1. Make sure SQLite3 is available to PHP
1. Make sure .registry.sqlite is writable by PHP
1. Visit index.php and see that the registry is empty
1. Visit index.php?username=<user>&ip=<ip>&corename=<corename>&coreversion=<coreversion>&gamename=<gamename>&gamecrc=<gamecrc> to add an entry
1. Visit index.php and see your new entry added
1. Clone repository: `git clone https://github.com/RobLoach/libretro-netplay-registry.git`
2. Go into the directory: `cd libretro-netplay-registry`
3. Install dependencies: `composer install`
4. Create database: `php bin/console doctrine:database:create`

## Development
# Development

Use [Docker Compose](https://docs.docker.com/compose/) to set up a development environment. Instructions are in [docker-compose.yml](docker-compose.yml).
1. Follow the installation.
2. Run application: `php bin/console server:run`

## TODO
# TODO

- Add some validation and security behind adding entries
* Add some validation and security behind adding entries.
* Add continuous integration.

## Hosting
# Hosting

The server, hosted at http://lobby.libretro.com is running the following software:
The server, hosted at [http://lobby.libretro.com](http://lobby.libretro.com) is running the following software:

- PHP 5.5.9
- SQLite3
- Apache
* PHP 5.5.9
* SQLite3
* Apache
7 changes: 7 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
7 changes: 7 additions & 0 deletions app/AppCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class AppCache extends HttpCache
{
}
50 changes: 50 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}

return $bundles;
}

public function getRootDir()
{
return __DIR__;
}

public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}

public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
11 changes: 11 additions & 0 deletions app/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

/** @var ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';

AnnotationRegistry::registerLoader([$loader, 'loadClass']);

return $loader;
66 changes: 66 additions & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en

framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection:
enabled: false
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
php_errors:
log: true

# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"

# Doctrine Configuration
doctrine:
dbal:
driver: pdo_sqlite
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
path: "%kernel.root_dir%/../var/data/data.sqlite"

orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
34 changes: 34 additions & 0 deletions app/config/config_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
imports:
- { resource: config.yml }

framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }

web_profiler:
toolbar: true
intercept_redirects: false

monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info

#swiftmailer:
# delivery_addresses: ['[email protected]']
21 changes: 21 additions & 0 deletions app/config/config_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
imports:
- { resource: config.yml }

#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc

monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
16 changes: 16 additions & 0 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
imports:
- { resource: config_dev.yml }

framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false

web_profiler:
toolbar: false
intercept_redirects: false

swiftmailer:
disable_delivery: true
19 changes: 19 additions & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"

mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~

# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt
8 changes: 8 additions & 0 deletions app/config/routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app:
resource: "@AppBundle/Controller/"
type: annotation

app_api:
resource: "@AppBundle/Controller/API/"
type: annotation
prefix: /api
14 changes: 14 additions & 0 deletions app/config/routing_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt

_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler

_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error

_main:
resource: routing.yml
Loading