Git Product home page Git Product logo

demo's Introduction

Symfony Demo Application

The "Symfony Demo Application" is a reference application created to show how to develop applications following the Symfony Best Practices.

You can also learn about these practices in the official Symfony Book.

Requirements

Installation

There are 3 different ways of installing this project depending on your needs:

Option 1. Download Symfony CLI and use the symfony binary installed on your computer to run this command:

symfony new --demo my_project

Option 2. Download Composer and use the composer binary installed on your computer to run these commands:

# you can create a new project based on the Symfony Demo project...
composer create-project symfony/symfony-demo my_project

# ...or you can clone the code repository and install its dependencies
git clone https://github.com/symfony/demo.git my_project
cd my_project/
composer install

Option 3. Click the following button to deploy this project on Platform.sh, the official Symfony PaaS, so you can try it without installing anything locally:

Deploy on Platform.sh

Usage

There's no need to configure anything before running the application. There are 2 different ways of running this application depending on your needs:

Option 1. Download Symfony CLI and run this command:

cd my_project/
symfony serve

Then access the application in your browser at the given URL (https://localhost:8000 by default).

Option 2. Use a web server like Nginx or Apache to run the application (read the documentation about configuring a web server for Symfony).

On your local machine, you can run this command to use the built-in PHP web server:

cd my_project/
php -S localhost:8000 -t public/

Tests

Execute this command to run tests:

cd my_project/
./bin/phpunit

demo's People

Contributors

94noni avatar b-durand avatar bechir avatar bobdenotter avatar bocharsky-bw avatar coderberg avatar coil avatar davialexandre avatar dependabot[bot] avatar derrabus avatar dmaicher avatar elkuku avatar fabpot avatar grafikart avatar gromnan avatar javiereguiluz avatar mstrom avatar nicolas-grekas avatar ogizanagi avatar phpeek avatar rosier avatar seb-jean avatar sergiu-popa avatar stof avatar thepetermick avatar tobion avatar voronkovich avatar wouterj avatar xabbuh avatar yceruto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

demo's Issues

Paginator for backend

I'd like to add the paginator also in the backend and btw sorting the columns to improve the user experience

Duplicate instantiation of AppKernel in app.php

Hello.

According to the comments in app.php, in order to enable the Symfony Reverse Proxy, you must uncomment the lines:

// require_once __DIR__.'/../app/AppCache.php';
// $kernel = new AppKernel('prod', false);
// $kernel->loadClassCache();
// $kernel = new AppCache($kernel);
// Request::enableHttpMethodParameterOverride();

However, the AppKernel is instantied and the ClassCache is loaded right before this block.

Is there a reason for re-constructing the kernel and loading the ClassCache only after
require_once __DIR__.'/../app/AppCache.php';?

Thank you!

Update readme to clarify that latest symfony installer is required

I was using the 1.0.0 version of the symfony installer, and issuing the command:

$ symfony demo

resulted in:

[InvalidArgumentException]      
Command "demo" is not defined.

I know that the latest version of the symfony installer must be used, but, can it be specified better in the README?

Best regards,

How to name the services?

We use app.twig.locale_extension for a twig extension, but for a listener we use app.controller_listener instead of app.listener.controller_listener or app.listener.controller.

This project needs more visibility

Hi,
i think this project needs more visibility ! The official website never speaks about it. We should have a link to this repo in the homepage in Learn > Other ressources.
Also, we shoud have a link in the Documentation page in sidebar menu and in Symfony Best Practices section.

What do you think ? For now, beginners and others can't find this project if there are any link in the official website.

Add ircmaxell/password-compat as a dependency

I'm running the demo in 5.4 and when i go to the login page i get an error because the password_hash function doesn't exists in 5.4, we can add ircmaxell/password-compat as a dependency to solve this. if you are ok with this i can send a PR :)

PD: Sorry for my english, i'm noob

[RFC] Adding other types of tests

Right now we only provide some unit and functional tests. But in the real world, some developers are using BDD and other testing tools such as Codeception.

The Codeception guys have recently published this article about creating tests with their framework and the Symfony Demo application. They even forked the demo app to provide some tests (see a sample test).

Should we include one sample Codeception, BDD, etc. test in our application? If those tools require to install some packages and do some config changes, we could just provide the test file and add a help note explaining how should developers install and configure that particular tool. That way the demo app would keep being simple, but at the same time, we would make it even more useful.

What do you think?

Add a RSS channel

It could be interesting to add a channel in the frontend home page, so newcomers can see how to work with a new format

Add an example using an ajax request

Hello,

I think it can be useful to show a mini example of how Symfony deals with ajax request.

  • Form the view with javascript code to the controller handling and sending json or html directly
  • GET (and POST maybe) request(s)

Any thoughts?

symfony-demo/app/config/parameters.yml - should it be in the repository?

Is it not best practice to ensure parameters.yml is NEVER checked in?

I understand why it is here - to make sure it can be run out of the box,
So many projects I see always mistakenly commit this file at first.

http://symfony.com/blog/new-in-symfony-2-3-interactive-management-of-the-parameters-yml-file

"As those parameters can be different on your local machine, your testing environment, your production servers, and even between developers working on the same project, it is not recommended to store it in the project repository. Instead, the repository should contain a paramaters.yml.dist file with sensible defaults that can be used as a good starting point for everyone."

Would it not be safer to just put the database settings straight into config.yml with a comment saying you are best copying parameters.yml.dist to parameters.yml and adding database settings there. Then have a commented out block in config.yml

# help here explaining parameters.yml and parameters.yml.dist

#       driver:   "%database_driver%"
#       host:     "%database_host%"

This way it will run out the box, without a parameters.yml file.

  • { resource: parameters.yml } # this would need commented out too, with an explanation why.

Maybe I'm taking this too far, what are others thoughts?

Event driven design

With symfony 2.0, I had a lot of problems with the event driven design.

I took a long time until I understand the benefit of using the event dispatcher.

in my opinion, in the symfony best practices, there should exist a good example how to use the event dispatcher.

The controller listener is needed, but not a good example.
https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/EventListener/ControllerListener.php

maybe we can add an example like this
https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Controller/BlogController.php#L64
the controller can be reduced, if we dispatch a new.user event and add at least one event listener who is persisting the data to the database and maybe another one, which is doing something else.

there exists a lot of blog articles about thin controller, maybe we should try to implement a good case in the symfony demo.

what do you think about that?

Update policy

Do we need to discuss when the committed composer.lock file will be updated? For example, currently you will download an archive containing Symfony 2.7.0 (the latest Symfony version is 2.7.1).

Finish application internationalization

Right now the application defines just four translations keys. See:
https://github.com/symfony/symfony-demo/blob/master/app/Resources/translations/messages.en.xliff

We did this to have just a simple example of how to translate application interfaces using Symfony. I propose the following:

  • Extract all the strings from the public interface and add them to the messages.en.xliff file
  • Move all the backend related strings to the admin.en.xliff file to show an example of using translation catalogues
  • Once these tasks are finished, ask the community to contribute translations.

What do you think?

Delete confirmation

Why not create a confirmation message before deleting a post?. Something like this:

Option One: Using javascript into html of the delete button:

<input type="submit" value="Delete post" class="btn btn-lg btn-block btn-danger" onclick="confirm('Are you sure to delete this post?') || event.preventDefault()">

Option Two: Create a modal window using Twitter Bootstrap modal.
Option Three: Create a new page with the appropriate message. So, the current delete button was converted in an anchor to this page.

Or is there some reason why this behavior is not used?

Translation for sliding pagination controls

The KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig template configured for pagination has Previous and Next strings ready for translation, what we should do: translate this strings directly or override this template and include new keys like pagination.previous & pagination.next ?

Error with russian translation after installation

I have just installed symfony-demo, and i see this message:

An exception has been thrown during the rendering of a template ("Unable to load "/Users/arseny/www/symfony_demo/app/Resources/translations/messages.ru.xliff": [ERROR 94] Validation failed: no DTD found ! (in n/a - line 2, column 21)
[ERROR 76] Opening and ending tag mismatch: trans-unit line 198 and body (in n/a - line 254, column 16)
[ERROR 76] Opening and ending tag mismatch: body line 4 and file (in n/a - line 255, column 12)
[ERROR 76] Opening and ending tag mismatch: file line 3 and xliff (in n/a - line 256, column 9)
[ERROR 77] Premature end of data in tag xliff line 2 (in n/a - line 257, column 1)") in default/homepage.html.twig at line 14.

when i go to http://localhost:8000/en, everything is ok.

Update application translations

In #80 @b-durand finished translating the entire Symfony Demo application. Now we need to update all the existing translation files:

  • English (in #80)
  • French (in #80)
  • Spanish (in #82)
  • Russian (in #86)
  • Ukrainian (in #93)
  • Romanian
  • Brazilian Portuguese (in #84)
  • German (in #89)
  • Czech (in #90)

If you plan to update any of the existing translations, please add a comment to let others know that you are working on that.

And if you want to translate the application into other languages, you are more than welcome to do that. Thanks!

A week of symfony

It would be great to have a Symfony Demo highlights such as Silex development highlights

=> more visibility, more PR

Why are assets in app/Resources/ ?

This seems a bit strange to me. All assets are already ready compiled and ready to be used. Why not placing them in the web/ directory directly? (seems duplication for nothing)

Also, IIRC assets:install doesn't search through the app/Resources/assets directory.

Update demo to SF 2.7

Hi guys!,

How about updating SF to 2.7 in sake of consistency between docs ? . BR

Location of doctrine repositories

I just found out that repositories live in AppBundle\Repository in this demo app. However, in the docs we use AppBundle\Entity (see symfony/symfony-docs#1316 for some context for this decision).

We should choose one and update either the demo app or the generator and docs.

Ideas to improve demo app

Hi,

I've been checking this app as it will be soon the app I will show for new comers I work with (demo/initiation purpose).

If the idea of this app is to introduce basic stuff of Symfony, and moreover the best practices (so devs are going to check code+comments), I propose to add/change some data in it:

  • add more comments where some "symfony magic" happen (like on https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Entity/Post.php#L161 to explain a minimum doctrine's relations) => comments lead to questions/answers which is good
  • a symfony command (a create:user with arguments/options to show a simple implementation, I have in mind the fos user's one, but in a minimal way) => symfony is as good in web as CLI
  • more?

Make the comment published date translatable

Right now, the date format is 'M jS \a\t g:i a', which doesn't work very well for every language.

I'm not sure about what would be the best approach for this, but I really like the idea of adding a new message to store the date format. With that it would be possible for every language to have its own date format and we could also have distinct date formats for different parts of the application.

I actually tried this, but I found a problem with the approach. Because the application is using the fallback translator option to set the actual locale, it may (if there's not date format to the given locale) end up returning the the message key as the date format. Maybe we could change fallback to something like:

translator:      { fallback: ["%locale%", "en"] }

What do you think?

Add tests

According to the best practices, each page should at least have a smoke test. Currently, there is only one page with a test

Does not work out of the box if pdo_sqlite is not installed

I just downloaded the demo app (git clone) then installed the dependencies with composer and the project is installed with no warnings or errors.

When trying to load the fixtures, the doctrine command fails, since I dont have installed the SQLite driver in my dev box.

I wonder if this "dependency" can be set directly in composer or update the installation docs?

Best regards,

Running without native intl generates 500

At least /en/admin/post/ fails with the following error:

An exception has been thrown during the rendering of a template ("The Symfony\Component\Intl\DateFormatter\IntlDateFormatter::__construct() method's argument $locale value NULL behavior is not implemented. Only the locale "en" is supported. Please install the "intl" extension for full localization capabilities.")

Change default port in Usage section

Maybe is a good idea to change the default port in the Usage section of the README.md file because if you have apache or something listening in the same port the command returns

Server running on http://127.0.0.1:8000

Quit the server with CONTROL-C.
Built-in server terminated unexpectedly
Run the command again with -v option for more details

either with the -v flag the command returns

Server running on http://127.0.0.1:8000

Quit the server with CONTROL-C.
  RUN  '/usr/bin/php5' '-S' '127.0.0.1:8000' '/home/diego/develop/github/dosten/symfony-demo/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php'
  RES  1 Command did not run successfully
Built-in server terminated unexpectedly

The error isn't very specific if the user has some tool listening in the port 8000.

[Show code] Twig template code no shown when clear cache

when I clean the cache the twig template code is not shown in the modal window.

Debugging Twig_Template class:

/**
 * Returns the template source code.
 *
 * @return string|null The template source code or null if it is not available
 */
public function getSource()
{
    $reflector = new ReflectionClass($this);
    $file = $reflector->getFileName();

    if (!file_exists($file)) {
        return;
    }

    //...
}

The $reflector->getFileName() returns ..\vendor\twig\twig\lib\Twig\Environment.php(390) : eval()'d code and finally getSource() returns null:

twig-template-code

This happen the first time after clear cache for each twig template. Any idea what might be happening?

Create ShowSourceBundle

We should create a simple separate bundle (ShowSourceBundle) and move there the ControllerListener, SourceCodeExtension and related views.
Let's discuss!

Pagination: third-party bundle or ...?

IMO this project need the pagination feature for blog lists, in the FindLatest method we got a Post::NUM_ITEMS but it isn't enough. What do we use for it I guess a third-party bundle right ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.