Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Implemented registration form and improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lastzero committed Aug 22, 2018
1 parent 5e95f6a commit 6be5cc9
Show file tree
Hide file tree
Showing 59 changed files with 2,956 additions and 1,235 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sudo: false
php:
- 7.0
- 7.1
- 7.2

before_script:
- composer install --no-interaction
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Symlex - A complete framework stack for agile Web development based on Symfony a
[![Latest Stable Version](https://poser.pugx.org/symlex/symlex/v/stable.svg)](https://packagist.org/packages/symlex/symlex)
[![License](https://poser.pugx.org/symlex/symlex/license.svg)](https://packagist.org/packages/symlex/symlex)

Symlex is designed to be simple with few concepts to understand - so that you can start implementing instead of wasting time on Stack Overflow.
Since its first release in 2014, it has proven to be well suited for rapidly building microservices, CLI and single-page applications. It comes
complete with working examples from testing to forms and database abstraction. Simply delete what you don't need.
Symlex is designed to be simple with few concepts to understand - so that you can start implementing instead
of wasting time on Stack Overflow.
Since its first release in 2014, it has proven to be well suited for rapidly building microservices,
CLI and single-page applications. It comes complete with working examples from testing to forms and database
abstraction. Simply delete what you don't need.

The [kernel](https://github.com/lastzero/di-microkernel) is extremely lean and only creates a Symfony
service container for bootstrapping any application within its context.
Expand All @@ -16,7 +18,7 @@ performance compared to Symfony standard edition and many other frameworks.
It also prevents developers from thoughtlessly installing existing bundles without understanding
them. The result is less bloat and simpler, more maintainable and testable code that is fundamental for agile development.

Plain classes are used wherever possible to avoid vendor lock-in and enable framework independent code reuse.
Plain classes are used wherever possible to avoid vendor lock-in and enable framework independent code reuse. See also [TRADEOFFS.md](TRADEOFFS.md).

You can combine the PHP based backend with any JavaScript library or REST client. The front-end boilerplate is there for
your convenience and puts you straight on track for building impressive single-page applications with Webpack and Vue.js.
Expand All @@ -27,9 +29,11 @@ best practices by example.**

*Note: https://github.com/symlex/symlex-core contains the bootstrap and routers as reusable components.*

![Screenshot](docs/img/screenshot.png)

Setup
-----
Before you start, make sure you got PHP 7, Composer and Docker installed on your system (short [howto](OSX_HOWTO.md)
Before you start, make sure you got PHP 7, Composer and Docker installed on your system (short [howto](docs/OSX_HOWTO.md)
for Mac OS X users). Instead of using Docker, you can also setup your own runtime environment based on the existing
Docker configuration.

Expand Down
30 changes: 29 additions & 1 deletion TRADEOFFS.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
https://twitter.com/cramforce/status/910489995617562624
# Tradeoffs

## Potential reasons to use Symlex

- Symlex is designed to be simple with few concepts to understand
- Using Symlex results is more maintainable and testable code that is fundamental for agile development
- It has proven to be well suited for rapidly building microservices, CLI and single-page applications
- It comes complete with working examples
- Built on top of well documented and tested standard components
- Contains everything to create full-featured Web applications: Service container, REST routing & Twig template engine
- Lower complexity and improved performance compared to Symfony standard edition and many other frameworks
- Plain classes are used wherever possible to avoid vendor lock-in and enable framework independent code reuse
- While you can use Symfony Components and any other PHP library out there, you can not use Symfony bundles as they
make it easy to add tons of code to an application with very little work and understanding for what it does
(bundles are nothing else than libraries that come with their own, hidden service container configuration and bootstrap code)
- Even if you choose not use Symlex, you might find lots of inspiration for your own projects

## Potential reasons to not use Symlex

- Symlex has a small community so far, see [history](../README.md)
- Development is mostly driven by the needs of specific applications (development started to have a high-performance
replacement for FOSRestBundle)
- It is not good for developers who are not comfortable reading at least small amounts of framework code as not
everything is documented 100% (you are welcome as ask for help via email and send additional docs as pull request)
- Symlex is completely not suitable if you would like to or need to work with existing Symfony bundles
- Symlex is not good if you prefer configuration over coding
- Copy and pasting code from Stack Overflow or the Symfony documentation often won't work without
understanding it and adapting it a little e.g. when it comes to service configuration or routing
- Symlex still uses Silex for routing under the hood; a replacement for Silex is in development
16 changes: 10 additions & 6 deletions app/config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ services:
calls:
- [ 'connect', [ '%redis.host%', '%redis.port%' ] ]

captcha.builder:
class: Gregwar\Captcha\CaptchaBuilder

cache:
class: Symfony\Component\Cache\Simple\RedisCache
arguments:
Expand All @@ -32,12 +35,9 @@ services:
db:
class: Doctrine\DBAL\Connection
arguments:
- %db.options%
- "%db.options%"
- "@db.driver"

message_selector:
class: Symfony\Component\Translation\MessageSelector

yaml_loader:
class: Symfony\Component\Translation\Loader\YamlFileLoader

Expand All @@ -46,7 +46,7 @@ services:

translator:
class: Symfony\Component\Translation\Translator
arguments: [ "en", "@message_selector" ]
arguments: [ "en" ]
calls:
- [ addLoader, [ "yaml", "@yaml_loader" ] ]
- [ addLoader, [ "array", "@array_loader" ]]
Expand All @@ -71,4 +71,8 @@ services:
- "@mailer"
- "@twig"
- "@service.token_generator"
- { %app.email%: %app.name%}
- { "%app.email%": "%app.name%" }

service.captcha:
class: App\Service\Captcha
arguments: [ "@cache", "@captcha.builder", "@service.token_generator" ]
3 changes: 2 additions & 1 deletion app/config/console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ imports:
services:
app:
class: Symfony\Component\Console\Application
arguments: [%app.name%, %app.version%]
public: true
arguments: [ "%app.name%", "%app.version%" ]
calls:
- [ setCatchExceptions, [ true ] ]
- [ setHelperSet, [ "@console.helpers" ] ]
Expand Down
12 changes: 6 additions & 6 deletions app/config/mailer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ services:
class: 'Swift_Transport_EsmtpTransport'
arguments: [ "@mailer_buffer", [ "@mailer_authhandler" ], "@mailer_eventdispatcher" ]
calls:
- [ setHost, [ %mailer.host% ] ]
- [ setPort, [ %mailer.port% ] ]
- [ setEncryption, [ %mailer.encryption% ] ]
- [ setUsername, [ %mailer.username% ] ]
- [ setPassword, [ %mailer.password% ] ]
- [ setAuthMode, [ %mailer.auth_mode% ] ]
- [ setHost, [ "%mailer.host%" ] ]
- [ setPort, [ "%mailer.port%" ] ]
- [ setEncryption, [ "%mailer.encryption%" ] ]
- [ setUsername, [ "%mailer.username%" ] ]
- [ setPassword, [ "%mailer.password%" ] ]
- [ setAuthMode, [ "%mailer.auth_mode%" ] ]

mailer_buffer:
class: 'Swift_Transport_StreamBuffer'
Expand Down
10 changes: 9 additions & 1 deletion app/config/rest.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
services:
router.rest:
class: App\Router\RestRouter
public: true
arguments: [ "@app", "@service_container" ]
calls:
- [ setSession, [ "@service.session" ] ]

controller.rest.v1.users:
class: App\Controller\Rest\V1\UsersController
public: true
arguments: [ "@service.session", "@model.factory", "@form.factory" ]
calls:
- [ setMailService, [ "@service.mail" ]]

controller.rest.v1.session:
class: App\Controller\Rest\V1\SessionController
arguments: [ "@service.session", "@model.user", %app.version%, %app.debug% ]
public: true
arguments: [ "@service.session", "@model.user", "%app.version%", "%app.debug%" ]

controller.rest.v1.registration:
class: App\Controller\Rest\V1\RegistrationController
public: true
arguments: [ "@service.captcha", "@service.mail", "@model.factory", "@form.factory"]
14 changes: 7 additions & 7 deletions app/config/twig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ services:

twig.loader:
class: Twig_Loader_Filesystem
arguments: [ %twig.path% ]
arguments: [ "%twig.path%" ]

twig:
class: Twig_Environment
arguments: [ "@twig.loader", %twig.options% ]
arguments: [ "@twig.loader", "%twig.options%" ]
calls:
- [ addGlobal, [ 'debug', %app.debug% ] ]
- [ addGlobal, [ 'app_name', %app.name% ] ]
- [ addGlobal, [ 'app_version', %app.version% ] ]
- [ addGlobal, [ 'app_url', %app.url% ] ]
- [ addGlobal, [ 'locale', %app.locale% ] ]
- [ addGlobal, [ 'debug', "%app.debug%" ] ]
- [ addGlobal, [ 'app_name', "%app.name%" ] ]
- [ addGlobal, [ 'app_version', "%app.version%" ] ]
- [ addGlobal, [ 'app_url', "%app.url%" ] ]
- [ addGlobal, [ 'locale', "%app.locale%" ] ]
- [ addExtension, [ '@twig.md5sum' ] ]
- [ addExtension, [ '@twig.trans' ] ]
7 changes: 6 additions & 1 deletion app/config/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ imports:
services:
app:
class: Silex\Application
public: true

request:
class: Symfony\Component\HttpFoundation\Request
Expand All @@ -18,17 +19,21 @@ services:

router.error:
class: App\Router\ErrorRouter
arguments: [ "@app", "@twig", %exception.codes%, %exception.messages%, %app.debug% ]
public: true
arguments: [ "@app", "@twig", "%exception.codes%", "%exception.messages%", "%app.debug%" ]
calls:
- [ setLogger, [ "@log" ] ]

router.twig:
class: Symlex\Router\TwigRouter
public: true
arguments: [ "@app", "@service_container", "@twig" ]

router.twig_default:
class: Symlex\Router\TwigDefaultRouter
public: true
arguments: [ "@app", "@service_container", "@twig" ]

controller.web.index:
public: true
class: App\Controller\Web\IndexController
14 changes: 13 additions & 1 deletion app/docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ RUN apk update \
nodejs \
nodejs-npm \
yarn \
zlib
zlib\
libpng\
libpng-dev\
libjpeg\
libjpeg-turbo-dev\
libwebp-dev\
freetype\
freetype-dev\
zlib\
zlib-dev

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

RUN docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) \
intl \
gd \
mbstring \
pdo_mysql \
sockets \
Expand Down
3 changes: 2 additions & 1 deletion app/l10n/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ form:
value_type_date: "%field% muss ein Datum sein"
value_type_time: "%field% must eine Uhrzeit sein"
value_type_datetime: "%field% ein Datum mit Uhrzeit sein"
value_type_switch: "%field% muss ausgewählt sein"
value_type_switch: "%field% muss ausgewählt sein"
captcha_not_valid: "Captcha ist nicht richtig"
3 changes: 2 additions & 1 deletion app/l10n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ form:
value_type_date: "%field% must be a date"
value_type_time: "%field% must be a time"
value_type_datetime: "%field% must be a date and time"
value_type_switch: "%field% must be selected"
value_type_switch: "%field% must be selected"
captcha_not_valid: "Captcha is not valid"
4 changes: 2 additions & 2 deletions app/templates/email/new_user.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Dear {{ firstname }},

Welcome to {{ app_name }}!

Click the link below to choose a password:
Please visit the link below to confirm your email and choose a password:

{{ app_url }}auth/password/{{ token }}
{{ app_url }}register/confirm/{{ token }}
4 changes: 3 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@

<target name="build-js">
<delete>
<fileset dir="./web/assets">
<fileset dir="./web/build">
<include name="*.js" />
<include name="*.css" />
<include name="*.eot" />
<include name="*.ttf" />
</fileset>
</delete>
<phingcall target="run-yarn"/>
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
}
],
"require": {
"php": ">=7.0",
"php": ">=7.1",
"ext-pdo_mysql": "*",
"symlex/symlex-core": "^3.3",
"symlex/input-validation": "^4.0",
"symlex/symlex-core": "^3.4",
"symlex/input-validation": "^4.2",
"symlex/doctrine-active-record": "^4.0",
"doctrine/dbal": "^2.5",
"doctrine/migrations": "^1.1",
"phing/phing": "^2.15",
"monolog/monolog": "^1.0",
"swiftmailer/swiftmailer": "^5.0",
"incenteev/composer-parameter-handler": "^2.0"
"incenteev/composer-parameter-handler": "^2.0",
"gregwar/captcha": "1.*"
},
"require-dev": {
"phpunit/phpunit": "^6.0",
Expand Down
File renamed without changes.
Binary file added docs/img/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions frontend/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const path = require('path');
// See https://github.com/webpack/loader-utils/issues/56
process.noDeprecation = true;

const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();

module.exports = (config) => {
const tests = 'tests/*/*.test.js';

Expand All @@ -11,11 +14,23 @@ module.exports = (config) => {

phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
exitOnResourceError: false
},

browsers: ['PhantomJS'],

browsers: ['ChromeHeadlessDocker'],
customLaunchers: {
'ChromeHeadlessDocker': {
base: 'ChromeHeadless',
flags: [
// We must disable the Chrome sandbox when running Chrome inside Docker (Chrome's sandbox needs
// more permissions than Docker allows by default)
// Also: https://github.com/GoogleChrome/puppeteer/issues/560
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-web-security'
],
},
},
files: [
{pattern: 'tests/**/*_test.js', watched: false}
],
Expand Down
Loading

0 comments on commit 6be5cc9

Please sign in to comment.