193 | {% endblock %}
194 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Resources/views/Default/knp_menu.html.twig:
--------------------------------------------------------------------------------
1 | {% extends 'knp_menu.html.twig' %}
2 | {% block label %}{{ item.label|trans(item.getExtra('translation_params', {}), item.getExtra('translation_domain', 'messages')) }}{% endblock %}
3 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Service/RandomUsernameGenerator.php:
--------------------------------------------------------------------------------
1 | version = $version;
23 | }
24 |
25 | /**
26 | * @return string
27 | */
28 | public function current()
29 | {
30 | return file_get_contents($this->version);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Controller/AccountControllerTest.php:
--------------------------------------------------------------------------------
1 | request('GET', 'account');
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Controller/DefaultControllerTest.php:
--------------------------------------------------------------------------------
1 | request('GET', '/en/');
14 |
15 | $this->assertTrue($crawler->filter('html:contains("Quickstart")')->count() > 0);
16 | }
17 |
18 | public function testIndexFr()
19 | {
20 | $client = static::createClient();
21 |
22 | $crawler = $client->request('GET', '/fr/');
23 |
24 | $this->assertTrue($crawler->filter('html:contains("Quickstart")')->count() > 0);
25 | }
26 |
27 | public function testChangelog()
28 | {
29 | $client = static::createClient();
30 |
31 | $crawler = $client->request('GET', '/changelog');
32 |
33 | $this->assertTrue($crawler->filter('html:contains("Changelog")')->count() > 0);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/DependencyInjection/ConfigurationSpec.php:
--------------------------------------------------------------------------------
1 | shouldHaveType('Quickstart\Bundle\AppBundle\DependencyInjection\Configuration');
14 | }
15 |
16 | /**
17 | * @TODO: Improve Spec
18 | */
19 | function it_should_get_config_tree_builder()
20 | {
21 | $this->getConfigTreeBuilder()
22 | ->shouldHaveType(new TreeBuilder());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/DependencyInjection/QuickstartAppExtensionSpec.php:
--------------------------------------------------------------------------------
1 | shouldHaveType('Quickstart\Bundle\AppBundle\DependencyInjection\QuickstartAppExtension');
14 | }
15 |
16 | /**
17 | * @TODO: Improve Spec
18 | */
19 | function it_should_load(ContainerBuilder $container)
20 | {
21 | $this->load(array(), $container);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/EventListener/RegistrationListenerSpec.php:
--------------------------------------------------------------------------------
1 | beConstructedWith($router, $generator);
19 | }
20 |
21 | function it_is_initializable()
22 | {
23 | $this->shouldHaveType('Quickstart\Bundle\AppBundle\EventListener\RegistrationListener');
24 | }
25 |
26 | function it_gets_subsribed_events()
27 | {
28 | $this->getSubscribedEvents()
29 | ->shouldBeArray();
30 | }
31 |
32 | function its_on_registration_init(
33 | UserEvent $userEvent,
34 | User $user,
35 | UrlGeneratorInterface $router,
36 | RandomUsernameGenerator $generator
37 | )
38 | {
39 | $generator
40 | ->getUsername()
41 | ->shouldBeCalled()
42 | ->willReturn('12345');
43 |
44 | $this->beConstructedWith($router, $generator);
45 |
46 | $user
47 | ->setUsername('12345')
48 | ->shouldBeCalled();
49 |
50 | $userEvent
51 | ->getUser()
52 | ->shouldBeCalled()
53 | ->willReturn($user);
54 |
55 | $this->onRegistrationInit($userEvent);
56 | }
57 |
58 | function its_on_registration_success(
59 | FormEvent $event,
60 | UrlGeneratorInterface $router,
61 | RandomUsernameGenerator $generator
62 | )
63 | {
64 | $router
65 | ->generate('quickstart_app_account')
66 | ->shouldBeCalled()
67 | ->willReturn('/en/account');
68 |
69 | $this->beConstructedWith($router, $generator);
70 |
71 | $event
72 | ->setResponse(
73 | Argument::type('Symfony\Component\HttpFoundation\RedirectResponse')
74 | )
75 | ->shouldBeCalled();
76 |
77 | $this->onRegistrationSuccess($event);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/Menu/MenuBuilderSpec.php:
--------------------------------------------------------------------------------
1 | createItem('root')->shouldBeCalled()->willReturn($menu);
20 | // $this->beConstructedWith($factory, true);
21 | // }
22 |
23 | function it_is_initializable(FactoryInterface $factory, SecurityContext $securityContext)
24 | {
25 | $this->beConstructedWith($factory, $securityContext);
26 | $this->shouldHaveType('Quickstart\Bundle\AppBundle\Menu\MenuBuilder');
27 | }
28 |
29 | function it_builds_the_menu_when_not_logged_in(FactoryInterface $factory, ItemInterface $menu, Request $request, SecurityContext $securityContext)
30 | {
31 | $menu->setChildrenAttributes(array('class' => 'navbar-nav nav'))
32 | ->shouldBeCalled()
33 | ->willReturn($menu);
34 |
35 | $menu->addChild('nav.home', array('route' => 'quickstart_app_homepage'))
36 | ->shouldBeCalled()
37 | ->willReturn($menu);
38 |
39 | $securityContext
40 | ->isGranted('IS_AUTHENTICATED_FULLY')
41 | ->shouldBeCalled()
42 | ->willReturn(false);
43 |
44 | $menu->addChild('nav.login', array('route' => 'fos_user_security_login'))
45 | ->shouldBeCalled()
46 | ->willReturn($menu);
47 |
48 | $menu->addChild('nav.register', array('route' => 'fos_user_registration_register'))
49 | ->shouldBeCalled()
50 | ->willReturn($menu);
51 |
52 | $factory->createItem('root')
53 | ->shouldBeCalled()
54 | ->willReturn($menu);
55 |
56 | $this->beConstructedWith($factory, $securityContext);
57 |
58 | $this->createMainMenu($request)->shouldHaveType('\Knp\Menu\ItemInterface');
59 | }
60 |
61 | function it_builds_the_menu_when_logged_in(
62 | FactoryInterface $factory,
63 | ItemInterface $menu,
64 | Request $request,
65 | SecurityContext $securityContext,
66 | TokenInterface $token,
67 | User $user
68 | )
69 | {
70 | $menu->setChildrenAttributes(array('class' => 'navbar-nav nav'))
71 | ->shouldBeCalled()
72 | ->willReturn($menu);
73 |
74 | $menu->addChild('nav.home', array('route' => 'quickstart_app_homepage'))
75 | ->shouldBeCalled()
76 | ->willReturn($menu);
77 |
78 | $securityContext
79 | ->isGranted('IS_AUTHENTICATED_FULLY')
80 | ->shouldBeCalled()
81 | ->willReturn(true);
82 |
83 | $securityContext
84 | ->getToken()
85 | ->shouldBeCalled()
86 | ->willReturn($token);
87 |
88 | $email = 'test@email.com';
89 | $user
90 | ->getEmail()
91 | ->shouldBeCalled()
92 | ->willReturn($email);
93 |
94 | $token
95 | ->getUser()
96 | ->shouldBeCalled()
97 | ->willReturn($user);
98 |
99 | $menu->addChild($email, array('route' => 'quickstart_app_account'))
100 | ->shouldBeCalled()
101 | ->willReturn($menu);
102 |
103 | $menu->addChild('nav.logout', array('route' => 'fos_user_security_logout'))
104 | ->shouldBeCalled()
105 | ->willReturn($menu);
106 |
107 | $factory->createItem('root')
108 | ->shouldBeCalled()
109 | ->willReturn($menu);
110 |
111 | $this->beConstructedWith($factory, $securityContext);
112 |
113 | $this->createMainMenu($request)->shouldHaveType('\Knp\Menu\ItemInterface');
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/QuickstartAppSpec.php:
--------------------------------------------------------------------------------
1 | shouldHaveType('Quickstart\Bundle\AppBundle\QuickstartAppBundle');
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/Service/RandomUsernameGeneratorSpec.php:
--------------------------------------------------------------------------------
1 | shouldHaveType('Quickstart\Bundle\AppBundle\Service\RandomUsernameGenerator');
14 | }
15 |
16 | function it_should_generate_a_string()
17 | {
18 | $this->getUsername()
19 | ->shouldBeString();
20 | }
21 |
22 | function it_should_generate_a_unique_username_each_time()
23 | {
24 | $this->getUsername()->shouldBeUnique();
25 | $this->getUsername()->shouldBeUnique();
26 | $this->getUsername()->shouldBeUnique();
27 | }
28 |
29 | public function getMatchers()
30 | {
31 | return array(
32 |
33 | 'beUnique' => function($value)
34 | {
35 | static $observedValues = array();
36 |
37 | if (in_array($value, $observedValues)) {
38 | return false;
39 | }
40 |
41 | $observedValues[] = $value;
42 | return true;
43 | },
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Quickstart/Bundle/AppBundle/Tests/Spec/Quickstart/Bundle/AppBundle/Service/VersionSpec.php:
--------------------------------------------------------------------------------
1 | beConstructedWith('version', true);
14 | }
15 |
16 | function it_is_initializable()
17 | {
18 | $this->shouldHaveType('Quickstart\Bundle\AppBundle\Service\Version');
19 | }
20 |
21 | function it_should_get_current_version()
22 | {
23 | $this->current()
24 | ->shouldReturn('-- unknown --');
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/behat.yml:
--------------------------------------------------------------------------------
1 | default:
2 | suites:
3 | default:
4 | contexts:
5 | - FeatureContext:
6 | session: '@session'
7 | quickstart_app:
8 | type: symfony_bundle
9 | bundle: QuickstartAppBundle
10 | filters:
11 | tags: ~@omit
12 | extensions:
13 | Behat\Symfony2Extension: ~
14 | Behat\MinkExtension:
15 | sessions:
16 | my_session:
17 | symfony2: ~
18 | selenium_session:
19 | selenium2: ~
20 | goutte_session:
21 | goutte: ~
22 | chartinger\Behat\TwigReportExtension\Extension:
23 | output:
24 | file: test/build/report.html
25 | templates:
26 | file: default.twig
27 | phantomjs:
28 | suites:
29 | default:
30 | contexts:
31 | - FeatureContext:
32 | session: '@session'
33 | quickstart_app:
34 | type: symfony_bundle
35 | bundle: QuickstartAppBundle
36 | extensions:
37 | Behat\Symfony2Extension: ~
38 | Behat\MinkExtension:
39 | base_url: 'http://localhost:8000'
40 | sessions:
41 | my_session:
42 | symfony2: ~
43 | phantomjs_session:
44 | selenium2:
45 | browser: phantomjs
46 | goutte_session:
47 | goutte: ~
48 | chartinger\Behat\TwigReportExtension\Extension:
49 | output:
50 | file: test/build/report.html
51 | templates:
52 | file: default.twig
53 |
--------------------------------------------------------------------------------
/test/build/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eddiejaoude/SymfonyQuickStart/ba7f4807f1fd7a750a999de4f3f8aef22277170e/test/build/.gitkeep
--------------------------------------------------------------------------------
/test/features/bootstrap/Quickstart/Bundle/AppBundle/Features/Context/FeatureContext.php:
--------------------------------------------------------------------------------
1 | getSession()->getPage();
23 |
24 | foreach ($table->getRows() as $row) {
25 | list($fieldSelector, $value) = $row;
26 |
27 | $field = $page->findField($fieldSelector);
28 | if (empty($field)) {
29 | $field = $this->getSession()->getDriver()->find('//label[contains(normalize-space(string(.)), "' . $fieldSelector . '")]');
30 | if (!empty($field)) {
31 | $field = current($field);
32 | }
33 | }
34 |
35 | if (empty($field)) {
36 | throw new \Exception('Field not found ' . $fieldSelector . PHP_EOL);
37 | }
38 |
39 | $tag = strtolower($field->getTagName());
40 |
41 | if ($tag == 'textarea') {
42 | $page->fillField($fieldSelector, $value);
43 | } elseif ($tag == 'select') {
44 | if ($field->hasAttribute('multiple')) {
45 | foreach (explode(',', $value) as $index => $option) {
46 | $page->selectFieldOption($fieldSelector, trim($option), true);
47 | }
48 | } else {
49 | $page->selectFieldOption($fieldSelector, $value);
50 | }
51 | } elseif ($tag == 'input') {
52 | $type = strtolower($field->getAttribute('type'));
53 | if ($type == 'checkbox' || $type == 'radio') {
54 | if (strtolower($value) == 'yes') {
55 | $page->checkField($fieldSelector);
56 | } else {
57 | $page->uncheckField($fieldSelector);
58 | }
59 | // } elseif ($type == 'radio') {
60 | // // TODO: handle radio
61 | } else {
62 | $page->fillField($fieldSelector, $value);
63 | }
64 | } elseif ($tag == 'label') {
65 | foreach (explode(',', $value) as $option) {
66 | $option = $this->fixStepArgument(trim($option));
67 | $field->getParent()->checkField($option);
68 | }
69 | }
70 | }
71 | }
72 |
73 | /**
74 | * @Given I am logged in as :arg1 with password :arg2
75 | */
76 | public function iAmLoggedInAsWithPassword($email, $password)
77 | {
78 | $this->visitPath('/');
79 | $this->getSession()->getPage()->clickLink('Login');
80 | $this->getSession()->getPage()->fillField('username', $email);
81 | $this->getSession()->getPage()->fillField('password', $password);
82 | $this->getSession()->getPage()->pressButton('_submit');
83 | }
84 |
85 | /**
86 | * @Given following users for each persona exist on system:
87 | */
88 | public function followingUsersForEachPersonaExistOnSystem(TableNode $table)
89 | {
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/test/phpspec.yml:
--------------------------------------------------------------------------------
1 | suites:
2 | default:
3 | namespace: Quickstart\Bundle\AppBundle
4 | spec_prefix: Spec
5 | spec_path: src/Quickstart/Bundle/AppBundle/Tests
6 |
7 | extensions:
8 | - PhpSpec\Extension\CodeCoverageExtension
9 |
10 | code_coverage:
11 | whitelist:
12 | - src/Quickstart/Bundle/AppBundle/DependencyInjection
13 | - src/Quickstart/Bundle/AppBundle/EventListener
14 | - src/Quickstart/Bundle/AppBundle/Menu
15 | - src/Quickstart/Bundle/AppBundle/Service
16 | whitelist_files:
17 | - src/Quickstart/Bundle/AppBundle/QuickstartAppBundle.php
18 | format:
19 | - html
20 | - clover
21 | output:
22 | html: test/build/coverage
23 | clover: test/build/coverage.xml
24 |
--------------------------------------------------------------------------------
/version:
--------------------------------------------------------------------------------
1 | -- unknown --
--------------------------------------------------------------------------------
/web/.htaccess:
--------------------------------------------------------------------------------
1 | # Use the front controller as index file. It serves as a fallback solution when
2 | # every other rewrite/redirect fails (e.g. in an aliased environment without
3 | # mod_rewrite). Additionally, this reduces the matching process for the
4 | # start page (path "/") because otherwise Apache will apply the rewriting rules
5 | # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
6 | DirectoryIndex app.php
7 |
8 |
9 | RewriteEngine On
10 |
11 | # Determine the RewriteBase automatically and set it as environment variable.
12 | # If you are using Apache aliases to do mass virtual hosting or installed the
13 | # project in a subdirectory, the base path will be prepended to allow proper
14 | # resolution of the app.php file and to redirect to the correct URI. It will
15 | # work in environments without path prefix as well, providing a safe, one-size
16 | # fits all solution. But as you do not need it in this case, you can comment
17 | # the following 2 lines to eliminate the overhead.
18 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
19 | RewriteRule ^(.*) - [E=BASE:%1]
20 |
21 | # Sets the HTTP_AUTHORIZATION header removed by apache
22 | RewriteCond %{HTTP:Authorization} .
23 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
24 |
25 | # Redirect to URI without front controller to prevent duplicate content
26 | # (with and without `/app.php`). Only do this redirect on the initial
27 | # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
28 | # endless redirect loop (request -> rewrite to front controller ->
29 | # redirect -> request -> ...).
30 | # So in case you get a "too many redirects" error or you always get redirected
31 | # to the start page because your Apache does not expose the REDIRECT_STATUS
32 | # environment variable, you have 2 choices:
33 | # - disable this feature by commenting the following 2 lines or
34 | # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
35 | # following RewriteCond (best solution)
36 | RewriteCond %{ENV:REDIRECT_STATUS} ^$
37 | RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
38 |
39 | # If the requested filename exists, simply serve it.
40 | # We only want to let Apache serve files and not directories.
41 | RewriteCond %{REQUEST_FILENAME} -f
42 | RewriteRule .? - [L]
43 |
44 | # Rewrite all other queries to the front controller.
45 | RewriteRule .? %{ENV:BASE}/app.php [L]
46 |
47 |
48 |
49 |
50 | # When mod_rewrite is not available, we instruct a temporary redirect of
51 | # the start page to the front controller explicitly so that the website
52 | # and the generated links can still be used.
53 | RedirectMatch 302 ^/$ /app.php/
54 | # RedirectTemp cannot be used instead
55 |
56 |
57 |
--------------------------------------------------------------------------------
/web/app.php:
--------------------------------------------------------------------------------
1 | unregister();
14 | $apcLoader->register(true);
15 | */
16 |
17 | require_once __DIR__.'/../app/AppKernel.php';
18 | //require_once __DIR__.'/../app/AppCache.php';
19 |
20 | $kernel = new AppKernel('prod', false);
21 | $kernel->loadClassCache();
22 | //$kernel = new AppCache($kernel);
23 |
24 | // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
25 | //Request::enableHttpMethodParameterOverride();
26 | $request = Request::createFromGlobals();
27 | $response = $kernel->handle($request);
28 | $response->send();
29 | $kernel->terminate($request, $response);
30 |
--------------------------------------------------------------------------------
/web/app_dev.php:
--------------------------------------------------------------------------------
1 | loadClassCache();
27 | $request = Request::createFromGlobals();
28 | $response = $kernel->handle($request);
29 | $response->send();
30 | $kernel->terminate($request, $response);
31 |
--------------------------------------------------------------------------------
/web/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/eddiejaoude/SymfonyQuickStart/ba7f4807f1fd7a750a999de4f3f8aef22277170e/web/apple-touch-icon.png
--------------------------------------------------------------------------------
/web/config.php:
--------------------------------------------------------------------------------
1 | getFailedRequirements();
20 | $minorProblems = $symfonyRequirements->getFailedRecommendations();
21 |
22 | ?>
23 |
24 |
25 |
26 |
27 |
28 | Symfony Configuration
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
Welcome!
66 |
Welcome to your new Symfony project.
67 |
68 | This script will guide you through the basic configuration of your project.
69 | You can also do the same by editing the ‘app/config/parameters.yml’ file directly.
70 |
71 |
72 |
73 |
Major problems
74 |
Major problems have been detected and must be fixed before continuing:
75 |
76 |
77 |
getHelpHtml() ?>
78 |
79 |
80 |
81 |
82 |
83 |
Recommendations
84 |
85 | Additionally, toTo enhance your Symfony experience,
86 | it’s recommended that you fix the following:
87 |
*
97 | getPhpIniConfigPath()): ?>
98 | Changes to the php.ini file must be done in "getPhpIniConfigPath() ?>".
99 |
100 | To change settings, create a "php.ini".
101 |
102 |