Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Added a "Welcome Page" for new Symfony apps #834

Closed
wants to merge 6 commits into from

Conversation

javiereguiluz
Copy link
Member

Problem

When you create a new Symfony app (symfony new my_project) and follow the installer instructions, when browsing the application for the first time, you'll get a 404 error:

old_welcome_screen

Solution

In this PR we add a new simple welcome page to avoid that error. This page is designed for newcomers, so we'll guide them exactly to where they should go: to the doc explaining how to create their first page with Symfony:

new_welcome_screen_ok

{% endblock %}

{% block stylesheets %}
<style type="text/css">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type attribute is redundant and not required

@Pierstoval
Copy link
Contributor

I don't think that writing the whole logic of the welcome page directly in the DefaultController is a good idea... Isn't it possible to add this behavior in another controller from the framework and do a simple forward?

We removed the entire AcmeDemoBundle a little because of the fact that installing a new Symfony app implied removing this bundle manually, so adding a lot of code again that would have to be removed by the devs seems quite a "rewind back"...?

*/
public function indexAction()
{
return $this->render('default/index.html.twig');
require_once __DIR__.'/../../../app/SymfonyRequirements.php';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about this, something like:

// replace this example code with whatever you need

@weaverryan
Copy link
Member

@Pierstoval The logic is just a couple of lines of code - that's quite easy to remove.

👍

@javiereguiluz is already aware of this, but we'll need a docs PR when this is merged - it requires some screenshots, so there's no use doing it before a merge.

@javiereguiluz
Copy link
Member Author

I've done the suggested changes.

Given that the current situation is dreadful (the first thing you see about Symfony is an error page) I ask you to please make a decision about this PR as quickly as possible. Thanks!

@lyrixx
Copy link
Member

lyrixx commented Jul 22, 2015

👍

@pgodel
Copy link

pgodel commented Jul 22, 2015

Great improvement!

👍

@ogizanagi
Copy link
Contributor

👍

@@ -12,6 +12,7 @@ public function testIndex()

$crawler = $client->request('GET', '/');

$this->assertTrue($crawler->filter('html:contains("Homepage")')->count() > 0);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertContains('Welcome to Symfony', $client->getResponse()->getContent());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest keeping a crawler-based example too in the test (or remove the unused $crawler variable)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I've changed it by:

$this->assertContains('Welcome to Symfony', $crawler->filter('#container h1')->text());

Thanks.

@TomasVotruba
Copy link

👍

1 similar comment
@hason
Copy link
Contributor

hason commented Jul 22, 2015

👍

@mykiwi
Copy link
Contributor

mykiwi commented Jul 22, 2015

👍

</svg>

Read Symfony documentation to learn
<a href="http://symfony.com/doc/{{ symfony_version }}/book/page_creation.html">How to create your first page in Symfony</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use constant('\\Symfony\\Component\\HttpKernel\\Kernel::VERSION') here as well? Symfony.com is capable of handling x.y.z versions in the URL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip. I've simplified the template. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought of a case that is no longer supported: unstable versions (where the version will be 2.8-dev for instance of 2.8-rc1).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you shouldn't use a leading slash in the class name. Class names are defined without that slash.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell removed the leading slash. Thanks!

@wouterj what about making this check for unstable versions?

{{ symfony_version|length > 3 ? 'current' : symfony_version }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz just thought of a nicer solution: {{ symfony_version[:3] }}. If the version is 2.7.3, it'll link to /doc/2.7/book/... and when the version is 3.0-dev, it'll link to /doc/3.0/book/..., which is redirected to /doc/master/book/....

Btw, can you please add the 2.8 version to the documentation?

@trq
Copy link

trq commented Jul 22, 2015

This is a simple but very effective improvement in my opinion. Great idea @javiereguiluz

@gnugat
Copy link

gnugat commented Jul 23, 2015

I think we're trying to mix two different concepts here:

  • providing a skeleton allowing developers to start writing their application right away
  • checking if the environment is correctly set up

When I use the standard edition, I don't directly open a page in the browser: I first start writing my app and then I'll check it later.
AcmeDemoBundle was removed because its purpose was to showcase the code of a Symfony application, and having it in the standard edition just slowed down developers who actually want to just start coding.

On the other hand, I do think we're missing a good tool to check if the environment is set up correctly. But I'd rather see it as a standalone script you could run everywhere.

@javiereguiluz
Copy link
Member Author

For people using the Symfony Installer, all technical requirements are checked during the installation and you can see the list of things to fix. In case you ignore this list, the first thing you'll see in the browser is the message telling you that some requirements aren't met.

For people still using Composer to install Symfony, they don't get the nice requirements checker of the installer, so it's nice to see the welcome page reminding them about these errors.

For Symfony experts, the new welcome page is just a 3 lines controller and 1 Twig template. They will clean everything very easily.

@cordoval
Copy link
Contributor

Contrary to the common denominator I am 👎 because this creates confusion, maybe even documented confusion. I would have initially thought that a default route on / is more than enough.

@javiereguiluz
Copy link
Member Author

@cordoval I don't understand your comment 😕 This PR is precisely to provide a default route to /, which currently is missing.

@cordoval
Copy link
Contributor

Instead of the demo doing a /examples/page, it could just be /. The demo in the first place missed the point completely.

@wouterj
Copy link
Member

wouterj commented Jul 23, 2015

I have a bit the same feeling as @cordoval and @gnugat. I would love to keep these things simple, as it now contains quite a bit of very confusing things (e.g. require_once in the controller, data urls, lots of logic).

What about removing the requirement check and just link to /web/check.php?

@cordoval
Copy link
Contributor

My feeling is broader actually, I remember those days in which symfony was simple 😊 and that we were happy escaping the magic of sf14 and give freedom to users. I know it is a hard critic, I did one project in sf14 for an old client recently and it felt to me simpler than working with symfony2. That feeling sank in me heavily.

@wouterj
Copy link
Member

wouterj commented Jul 23, 2015

I have the feeling that your comments are completely not related to this PR, @cordoval. Can you maybe create a new issue for your thoughts on this (as it can lead to interesting results, when thinking about what can be made easier?) in the symfony repository and avoid the noise here? Thanks! 😃

@javiereguiluz
Copy link
Member Author

@wouterj I like your last proposal. I've simplified everything in 3196523. Thanks.

@Pierstoval
Copy link
Contributor

@cordoval I don't understand why things are "more complicated" with this PR, even if I'm 👎 for the way it was implemented.

For the rest, I still think that, even if its "only 3 lines of code and a template", it's still much more than "one single line of code" for me...

@wouterj
Copy link
Member

wouterj commented Jul 23, 2015

👍 for the current state and merging this one quickly

@fabpot
Copy link
Member

fabpot commented Jul 23, 2015

@javiereguiluz Can you update the screenshot in the description to avoid comments about the previous version?

@javiereguiluz
Copy link
Member Author

Done.

@fabpot
Copy link
Member

fabpot commented Jul 23, 2015

👍

1 similar comment
@weaverryan
Copy link
Member

👍

@sstok
Copy link

sstok commented Jul 23, 2015

It's not magical or anything (like that it's part of the FrameworkBundle defining a default route), its a sensible default with a single page (not a complete bundle). And you are going to change (rather then delete - aka more work) these files anyway, so 👍 for me.

@cordoval

My feeling is broader actually, I remember those days in which symfony was simple 😊 and that we were happy escaping the magic of sf14 and give freedom to users. I know it is a hard critic, I did one project in sf14 for an old client recently and it felt to me simpler than working with symfony2. That feeling sank in me heavily.

Never used Symfony 1.4 :) so can't really tell, what is simple is not automatically easy.
I understand your point, simple implies (simplistic or minimalistic) while easy describes (easy to use and change). I agree on the 'its starts directly from the box' vs 'clean from the box', that it's better (simpler) to get started directly without having to remove allot of demo code. But we also want to keep the experience to be easy and pleasant for newcomers.

@@ -4,15 +4,17 @@

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided at some point to keep such a use statement to make it easier for people to start working right away. Not sure if we need to keep it now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep it, it should at least be in the indexAction method to show why its here.

@gnugat
Copy link

gnugat commented Jul 23, 2015

@javiereguiluz
For people using the Symfony Installer, all technical requirements are checked during the installation and you can see the list of things to fix. In case you ignore this list, the first thing you'll see in the browser is the message telling you that some requirements aren't met.

For people still using Composer to install Symfony, they don't get the nice requirements checker of the installer, so it's nice to see the welcome page reminding them about these errors.

For Symfony experts, the new welcome page is just a 3 lines controller and 1 Twig template. They will clean everything very easily.

I wouldn't use the installer nor composer bootstrap when creating a new server for an existing sf app. I'm actually longing for a standalone script that could be used anywhere, but that's another topic, sorry for bringing it here.

Now back to the actual PR: I don't get the point of having a default page when all I want is an empty skeleton.

@weaverryan
Copy link
Member

@gnugat I helped a user on Twitter just last week - they got the 404 page and thought that tons of things must be broken with their setup because they got an error page when first loading things up. That's the point.

@gnugat
Copy link

gnugat commented Jul 23, 2015

@weaverryan in the case of developers trying out Symfony for the first time, doesn't it make sense to provide them a different application (let's say the AcmeDemo show case application)? To me it sounds more like a lack of explanation / choice on the download page.

@pgodel
Copy link

pgodel commented Jul 23, 2015

Guys, we are trying to help the newcomers, if you already know Symfony, you will know that you need to delete 3 lines of code and one twig template, and that won't take much time even if you have to do it multiple times.

For a newcomer this change can make a big difference.

@Pierstoval
Copy link
Contributor

@gnugat It depends of what kind of "newcomer" you are. In my case, when I want to discover new frameworks/languages, I won't look at the code at first. I'll create an app. So in the case of Symfony, if I had to discover it today, I'd create an app and start to code right now by following the docs/books.

Even if the Symfony Demo app is great in many points, it depends on each person, and IMO is more for presentations and learnings.

And many other developers will give you different answers. That's why providing a very small working skeleton is absolutely important.

@fabpot
Copy link
Member

fabpot commented Jul 23, 2015

Thank you @javiereguiluz.

fabpot added a commit that referenced this pull request Jul 23, 2015
This PR was squashed before being merged into the 2.3 branch (closes #834).

Discussion
----------

Added a "Welcome Page" for new Symfony apps

### Problem

When you create a new Symfony app (`symfony new my_project`) and follow the installer instructions, when browsing the application for the first time, you'll get a 404 error:

![old_welcome_screen](https://cloud.githubusercontent.com/assets/73419/8820296/760f30fc-3054-11e5-9251-d382a5257758.png)

### Solution

In this PR we add a new simple welcome page to avoid that error. This page is designed for newcomers, so we'll guide them exactly to where they should go: to the doc explaining how to create their first page with Symfony:

![new_welcome_screen_ok](https://cloud.githubusercontent.com/assets/73419/8820314/97ee4258-3054-11e5-8ef8-f4f8c93bb899.png)

Commits
-------

0e4bb3e Added a "Welcome Page" for new Symfony apps
@fabpot fabpot closed this Jul 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.