Thanks to visit codestin.com
Credit goes to github.com

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

Added a new AppBundle to comply with Symfony Best Practices #728

Closed
wants to merge 5 commits into from
Closed

Added a new AppBundle to comply with Symfony Best Practices #728

wants to merge 5 commits into from

Conversation

javiereguiluz
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #671
License MIT
Doc PR -

Symfony Best Practices recommend to start developing your applications with a single AppBundle bundle. This PR allows to include that AppBundle in the Symfony Standard Edition, to make it easier for developers.

I used the same skeleton as for the generate:bundle command, but I thought that it would be better to simplify it and remove the $name route parameter and use just a static template without parameters.

@@ -23,3 +23,6 @@ monolog:
level: debug
console:
type: console

assetic:
use_controller: false
Copy link
Member

Choose a reason for hiding this comment

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

this is useless, as it is already the default

@gnugat
Copy link

gnugat commented Oct 21, 2014

Fixes issue #671

@javiereguiluz
Copy link
Member Author

@gnugat updated PR description. Thanks!

@javiereguiluz
Copy link
Member Author

fabbot says that the name of the test class is wrong:

fabbot_error

I don't know what to do in this case.

@stof
Copy link
Member

stof commented Oct 21, 2014

@javiereguiluz fix the filename actually

@javiereguiluz
Copy link
Member Author

@stof thanks! I feel really stupid right now for having made this mistake :(

@@ -0,0 +1 @@
Homepage.
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to extend the base template since that is also shipped with the standard edition?

Copy link
Member

Choose a reason for hiding this comment

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

agreed. It would be better to make it HTML rather than returning plain text in an HTML response

Copy link
Member Author

Choose a reason for hiding this comment

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

@xabbuh it truly makes A LOT of sense! Thanks for suggesting this improvement.

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

So the standard edition is going into the direction of RAD? Pretty unusable for medium to large projects.

@gnugat
Copy link

gnugat commented Oct 21, 2014

@Tobion what would you suggest?

@javiereguiluz
Copy link
Member Author

@Tobion this will be the last significant PR related to best practices for the standard edition. The only changes that we've made are:

  • Creating a app/config/services.yml and importing it from config.yml
  • Creating an almost empty AppBundle and configure its routing via annotations.
  • Providing one sample template in the app/Resources/views/default/ directory.
  • Remove some parameters from app/config/parameters.yml.dist

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

I thought that's what the "editions" are for. So why not introduce a RAD edition? If the RAD version is the standard-edition then, most advanced people will just be busy deleting the AppBundle again. Just as it was for the DemoBundle.

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

This PR also conflicts with #723

@javiereguiluz
Copy link
Member Author

@Tobion I think we have different opinions about what is a RAD edition: you think that this PR may turn the standard edition into a RAD edition. I think that a RAD edition should be much more heavily modified, like the one developed by KnpLabs (rad.knplabs.com).

The other point where we don't agree is where you say that this AppBundle is unusable for medium to large projects.

And finally, I think that there is a big difference between AcmeDemoBundle and AppBundle. The demo bundle is useful to almost nobody (only some newcomers) and the AppBundle can be useful for lots of people (newcomers, small projects, medium projects, people following the best practices, etc.)

@@ -0,0 +1,3 @@
app:
resource: @AppBundle/Controller/
Copy link
Member

Choose a reason for hiding this comment

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

should be "@AppBundle/Controller/"

@wouterj
Copy link
Member

wouterj commented Nov 7, 2014

I would propose to merge this into 2.3 actually. The best practices are for everyone, not people living on the edge. We'll also have a problem in the documentation when only 2.6+ has the AppBundle. We should assume one consistent state of new projects, currently we can't do that. That'll result in either confusing docs or many extra doc maintaining hours.

@stof
Copy link
Member

stof commented Nov 21, 2014

👍

and I agree with @wouterj about providing best-practices-ready projects for people creating a new project based on the LTS too. what do you think @fabpot ?

@samsonasik
Copy link

symfony 2.6 just released, I think it need to be merge then to support symfony best practice that said : "If you are using Symfony 2.6 or a newer version, the AppBundle bundle is already generated for you".

@fabpot
Copy link
Member

fabpot commented Nov 29, 2014

Thank you @javiereguiluz.

@fabpot fabpot closed this in 9a383da Nov 29, 2014
@samsonasik
Copy link

@fabpot it is need to be included in tag with 2.6.0, isn't it ?

@webdevilopers
Copy link

👍

fabpot added a commit that referenced this pull request Dec 2, 2014
…ces (javiereguiluz)

This PR was squashed before being merged into the 3.0-dev branch (closes #728).

Discussion
----------

Added a new AppBundle to comply with Symfony Best Practices

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #671
| License       | MIT
| Doc PR        | -

Symfony Best Practices recommend to start developing your applications with a single AppBundle bundle. This PR allows to include that AppBundle in the Symfony Standard Edition, to make it easier for developers.

I used the same skeleton as for the `generate:bundle` command, but I thought that it would be better to simplify it and remove the `$name` route parameter and use just a static template without parameters.

Commits
-------

45da0d0 Added a new AppBundle to comply with Symfony Best Practices
fabpot added a commit that referenced this pull request Dec 2, 2014
* 2.3:
  feature #728 Added a new AppBundle to comply with Symfony Best Practices (javiereguiluz)
fabpot added a commit that referenced this pull request Dec 2, 2014
* 2.5:
  feature #728 Added a new AppBundle to comply with Symfony Best Practices (javiereguiluz)
fabpot added a commit that referenced this pull request Dec 2, 2014
* 2.6:
  feature #728 Added a new AppBundle to comply with Symfony Best Practices (javiereguiluz)
  fixed Symfony version dep
  updated VENDORS for 2.6.0-BETA2

Conflicts:
	composer.json
fabpot added a commit that referenced this pull request Dec 2, 2014
* 2.7:
  feature #728 Added a new AppBundle to comply with Symfony Best Practices (javiereguiluz)
  fixed Symfony version dep
  updated VENDORS for 2.6.0-BETA2
@velikanov
Copy link

👎
@wouterj, @world it's actual for newcomers only
what the need of having AppBundle when I'm able to generate:bundle, which must generate me the bundle with all the best practices in? (but not that /hello/{name} stuff actually you know)
for me it's irrationally

but the wiping out the AppBundle is annoying experience in new projects if you want to create your own bundle(s)

I don't think that anyone prefer to rename bundle dir, route, class, the include in AppKernel rather than just generate new bundle in empty environment

that's my position

I hope it will be wiped cleanly out in 2.7 and sure in 3.0

there's too much attention for bundle generation in docs to leave it as it was all time

So, my proposition is to ask user for creation of AppBundle (without vendor namespace and so on) just as like as asking about AcmeHelloBundle you know…

thank you all

@wouterj
Copy link
Member

wouterj commented Dec 8, 2014

Could you please explain your vote, @velikanov?

@stof
Copy link
Member

stof commented Dec 16, 2014

@velikanov the goal is to update the doc to remove the need of generating a bundle, to make things easier to create new projects. It is just that the doc updates are still in progress

@velikanov
Copy link

@stof, maybe I don't get the full idea
but I really can't understand why do I need an AppBundle instead of empty src dir and bundle generator?
for me it looks ridiculous, sorry

@stof
Copy link
Member

stof commented Dec 16, 2014

@velikanov a bundle generator means that newcomers have an extra step to do before being able to start. And given that the best practices are saying to call it AppBundle anyway, the command would be the same for everyone

@javiereguiluz
Copy link
Member Author

@velikanov we add a pre-generated AppBundle because we think that most people need it and use it for their applications. This way we can eliminate one step when starting to develop the application.

In any case, we are always careful about adding new things or pre-configuring things. We don't want to be "too clever" or to "outsmart our users", because most of the times, when you try to do that, you fail. So thanks for your comment and please, don't hesitate to point to us whenever you think we are doing unnecessary things.

@velikanov
Copy link

@stof, @javiereguiluz, I didn't ever create an AppBundle :(
it's maybe I'm not so best-practisized :)
for me it's more obvious to add ApiBundle for example, or CoreBundle, you know

@calinpristavu
Copy link

Although i'm +1 for the app bundle, imho situations like this one could be solved by giving the posibility to customize the name of the first bundle via an install interaction that defaults to "AppBundle" right?

@wouterj
Copy link
Member

wouterj commented Dec 16, 2014

@velikanov well, instead of naming it CoreBundle, it's AppBundle :)

The thing is, now we have the best practices and people have accepted it, an AppBundle will be used a lot. It's not "just for beginners", it's for everyone (even complex apps benefit a lot of having 1 not decoupled bundle instead of 10).

I don't think adding yet another question to the installation process is the solution. I believe this is just another point where people have to realize that it's just the SE. There is nothing that makes you bind to this edition, except that it's the one used in the docs. If you don't like something, create a fork and start your own edition.

@velikanov
Copy link

@wouterj, I know that my voice will completely not turn the decision, but I will never agree this)
for not-newcomers it's a two-step story: 1) wipeout the ridiculous AppBundle (that is without vendor name for sure), 2) generate a new bundle (/me always do Vendor/SomeBundle)
maybe we can omit the Vendor part of new bundle, but AppBundle (for me) is just like Acme/HelloBundle, but without Acme/ and without /hello/{name} route :lol:

@velikanov
Copy link

but, my words is like old man grumbling, don't take it serious)
newcomers are much more welcomed)

@velikanov
Copy link

but anyway 👎, sorry

@stof
Copy link
Member

stof commented Dec 16, 2014

@velikanov I suggest you to read http://knpuniversity.com/blog/AppBundle where @weaverryan explains the reasonning about the AppBundle (watching him talk about this at the SymfonyCon would be even better, but the videos are not yet online)

@velikanov
Copy link

@stof, yep I did and can't agree with this whole thing :(
but as I know, "Ok, not everyone agrees - it’s cool :)."
"YIIfy your Bundles"

@Pierstoval
Copy link
Contributor

I was a bit skeptical about AppBundle when I saw this new "feature", but in fact, the AppBundle would have been something I may have needed when I started Symfony 2 years ago.

After reading @weaverryan's article you posted @stof, I'm starting to think that the AppBundle is really a GREAT thing ! In fact, any new app can or cannot use it, and like the AcmeDemoBundle, it's simply a matter of personal judgement.
In a few days/weeks I'll have to start a small app, basically an app with 4 pages, 2 front and 2 backs', and as there are many rules to adapt (forms, entities, mails...), using Symfony is the best idea. I know that my code won't be reused, at least for now, so I don't need to use the classical src/vendor/stuffbundle directory, a simple "AppBundle" is enough.

@velikanov you can also see the documentation about Silex : you create an app, and the first thing you develop is an app, especially when you're a beginner. So a simple "AppBundle" is really enough, especially with the upcoming new Symfony docs. I guess they'll probably rely on testing our own features inside the AppBundle instead of the AcmeDemoBundle.

When you know Symfony, and when you need a "bigger" app, then just use the classical Bundle structure, remove the AppBundle like you would have removed the AcmeDemoBundle before.
But when you're a beginner, you download Symfony, you install it, and you may not understand the structure. So, you look at the documentation, and see that the AcmeDemoBundle is just a presentation of the framework. The AppBundle is your sandbox.
When reading the docs for the first time, you see "Create your own Controller". Lucky ! There's an awesome blank one in the AppBundle, so I'll just read how it's made.
Generating bundle is great, though it's a feature that you will need when you will create bigger apps, which is never the purpose of a fresh beginner who wants to discover the framework.

As you can create a PHP app from-scratch without framework, you can create a Symfony app without any bundle, that's why AppBundle is great : it allows you to start doing messy stuff by putting everything in the same directory, for you to learn really better how to have a good architecture.
It's better than creating bundles for every feature you need right at the beginning, as it will force you to navigate through more and more directories.

I hope I understood well how the AppBundle was born 😄

@velikanov
Copy link

👍
finally, I got an idea
this rocks

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.