Commit Graph

44 Commits

Author SHA1 Message Date
Fabien Potencier
5a528bcb55 [FrameworkBundle] change cache:clear warmup option to no-warmup as most of the time people will want to use the warmup version (especially in production env) 2011-03-21 09:39:28 +01:00
Fabien Potencier
00d47889a2 [FrameworkBundle] removed hardcoded AppKernel class name 2011-03-21 09:33:58 +01:00
Fabien Potencier
b00a903858 [FrameworkBundle] removed clearDir() method in some commands (use Filesystem::remove() instead) 2011-03-21 09:31:04 +01:00
Fabien Potencier
45f9c2fbf4 merged francisbesset:cache_clear_command 2011-03-21 09:24:16 +01:00
Fabien Potencier
d9c5102fd6 [FrameworkBundle] miror changes to container:debug 2011-03-14 14:24:45 +01:00
Fabien Potencier
b93a2c39a8 Merge remote branch 'weaverryan/container_debug_console' 2011-03-14 14:17:08 +01:00
Ryan Weaver
0f0539f983 [FrameworkBundle] Adding lots of information for the user after init:bundle
This is mirrored off of the messages used by git flow and serves to give the user some initial direction (and to avoid "forgetting" the setup steps).

I realize that I've hardcoded documentation URLs into this task, but I think the benefit outweighs the cost of needing to make sure these are always up-to-date.
2011-03-13 12:08:56 -05:00
Ryan Weaver
a495fa3dce [FrameworkBundle] Adding a container:debug console
This command uses a new container pass which dumps the ContainerBuilder into a cache file by serializing it. It's possible that we don't want this to run when kernel.debug = false, but I don't see the harm of generating the file and running the container:debug in, for example, the prod environment seems to make sense.
2011-03-12 14:44:21 -06:00
Francis Besset
74bae0444f [FrameworkBundle] Fixed indentation on router:debug command 2011-03-12 14:08:29 +01:00
Francis Besset
bb7986e221 [FrameworkBundle] Added cache:clear command with warmup option 2011-03-11 23:35:48 +01:00
Fabien Potencier
b940cc6f40 moved most protected to private in the Console component 2011-03-11 12:53:42 +01:00
Fabien Potencier
8c423edfef replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00
Pascal Borreli
f7716645a5 [FrameworkBundle] Removed useless else 2011-02-27 18:36:36 +01:00
Fabien Potencier
d4fc3c98b1 [FrameworkBundle] updated the init:bundle skeleton files 2011-02-21 11:26:58 +01:00
Fabrice Bernhard
13469a2d82 [FrameworkBundle] added --format=xml,php,yml optional parameter to the init:bundle command
* Added the --format parameter to the InitBundleCommand.php file
* Moved all the non-format-dependent files from Resources/skeleton/bundle to Resources/skeleton/bundle/generic
* Created Resources/skeleton/bundle/[php,yml,xml] subfolders containing the files config/routing.[xml,yml,php]
2011-02-14 19:31:21 +01:00
Fabien Potencier
f35f1e1f3c [FrameworkBundle] fixed init:bundle command 2011-02-08 22:36:36 +01:00
Fabien Potencier
4e877a84ad [FrameworkBundle] fixed router:apache-dump command 2011-01-30 11:37:38 +01:00
Fabien Potencier
faf871990e fixed CS 2011-01-29 12:21:55 +01:00
Miha Vrhovnik
6ee13a6b8d Added optional parameter bundleName,
added namespace validation,
fixed dir trailing / handling
2011-01-29 12:18:44 +01:00
Benjamin Eberlei
bdbfb44a96 [DoctrineBundle] First round of cleanup the Command namespace in DoctrineBundle 2011-01-29 10:09:42 +01:00
Fabien Potencier
e645090423 moved security related things to a new SecurityBundle (the Security component is left unchanged) 2011-01-26 19:10:54 +01:00
Fabien Potencier
d0b4bfc8f6 added a cache warmer sub-framework
Cache warmer will come in the next commits.

To warm up the cache on a production server, you can use
the cache:warmup command:

./app/console_prod cache:warmup
2011-01-24 18:08:51 +01:00
Christophe Coevoet
1e793a2500 Fixed init:bundle 2011-01-21 14:19:51 +01:00
Fabien Potencier
4e0ecfdf81 [FrameworkBundle] fixed init:bundle 2011-01-21 12:58:46 +01:00
Fabien Potencier
6d1e91a1fa refactored bundle management
Before I explain the changes, let's talk about the current state.

Before this patch, the registerBundleDirs() method returned an ordered (for
resource overloading) list of namespace prefixes and the path to their
location. Here are some problems with this approach:

 * The paths set by this method and the paths configured for the autoloader
   can be disconnected (leading to unexpected behaviors);

 * A bundle outside these paths worked, but unexpected behavior can occur;

 * Choosing a bundle namespace was limited to the registered namespace
   prefixes, and their number should stay low enough (for performance reasons)
   -- moreover the current Bundle\ and Application\ top namespaces does not
   respect the standard rules for namespaces (first segment should be the
   vendor name);

 * Developers must understand the concept of "namespace prefixes" to
   understand the overloading mechanism, which is one more thing to learn,
   which is Symfony specific;

 * Each time you want to get a resource that can be overloaded (a template for
   instance), Symfony would have tried all namespace prefixes one after the
   other until if finds a matching file. But that can be computed in advance
   to reduce the overhead.

Another topic which was not really well addressed is how you can reference a
file/resource from a bundle (and take into account the possibility of
overloading). For instance, in the routing, you can import a file from a
bundle like this:

  <import resource="FrameworkBundle/Resources/config/internal.xml" />

Again, this works only because we have a limited number of possible namespace
prefixes.

This patch addresses these problems and some more.

First, the registerBundleDirs() method has been removed. It means that you are
now free to use any namespace for your bundles. No need to have specific
prefixes anymore. You are also free to store them anywhere, in as many
directories as you want. You just need to be sure that they are autoloaded
correctly.

The bundle "name" is now always the short name of the bundle class (like
FrameworkBundle or SensioCasBundle). As the best practice is to prefix the
bundle name with the vendor name, it's up to the vendor to ensure that each
bundle name is unique. I insist that a bundle name must be unique. This was
the opposite before as two bundles with the same name was how Symfony2 found
inheritance.

A new getParent() method has been added to BundleInterface. It returns the
bundle name that the bundle overrides (this is optional of course). That way,
there is no ordering problem anymore as the inheritance tree is explicitely
defined by the bundle themselves.

So, with this system, we can easily have an inheritance tree like the
following:

FooBundle < MyFooBundle < MyCustomFooBundle

MyCustomFooBundle returns MyFooBundle for the getParent() method, and
MyFooBundle returns FooBundle.

If two bundles override the same bundle, an exception is thrown.

Based on the bundle name, you can now reference any resource with this
notation:

    @FooBundle/Resources/config/routing.xml
    @FooBundle/Controller/FooController.php

This notation is the input of the Kernel::locateResource() method, which
returns the location of the file (and of course it takes into account
overloading).

So, in the routing, you can now use the following:

    <import resource="@FrameworkBundle/Resources/config/internal.xml" />

The template loading mechanism also use this method under the hood.

As a bonus, all the code that converts from internal notations to file names
(controller names: ControllerNameParser, template names: TemplateNameParser,
resource paths, ...) is now contained in several well-defined classes. The
same goes for the code that look for templates (TemplateLocator), routing
files (FileLocator), ...

As a side note, it is really easy to also support multiple-inheritance for a
bundle (for instance if a bundle returns an array of bundle names it extends).
However, this is not implemented in this patch as I'm not sure we want to
support that.

How to upgrade:

 * Each bundle must now implement two new mandatory methods: getPath() and
   getNamespace(), and optionally the getParent() method if the bundle extends
   another one. Here is a common implementation for these methods:

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'MyFrameworkBundle';
    }

    /**
     * {@inheritdoc}
     */
    public function getNamespace()
    {
        return __NAMESPACE__;
    }

    /**
     * {@inheritdoc}
     */
    public function getPath()
    {
        return strtr(__DIR__, '\\', '/');
    }

 * The registerBundleDirs() can be removed from your Kernel class;

 * If your code relies on getBundleDirs() or the kernel.bundle_dirs parameter,
   it should be upgraded to use the new interface (see Doctrine commands for
   many example of such a change);

 * When referencing a bundle, you must now always use its name (no more \ or /
   in bundle names) -- this transition was already done for most things
   before, and now applies to the routing as well;

 * Imports in routing files must be changed:
    Before: <import resource="Sensio/CasBundle/Resources/config/internal.xml" />
    After:  <import resource="@SensioCasBundle/Resources/config/internal.xml" />
2011-01-20 18:42:47 +01:00
Dominique Bongiraud
64fb94c725 normalized license messages in PHP files 2011-01-18 08:07:46 +01:00
Bertrand Zuchuat
ff82905c57 Typo on command asset:install 2011-01-15 20:11:45 +01:00
Fabien Potencier
7ac6d59173 changed the bundle name to be the class name of the bundle, not the last part of the namespace
Let's take some examples to explain the change.

First, if you don't use any vendored bundles, this commit does not change anything.

So, let's say you use a FooBundle from Sensio. The files are stored under Bundle\Sensio\FooBundle.
And the Bundle class is Bundle\Sensio\FooBundle\SensioFooBundle.php.

Before the change, the bundle name ($bundle->getName()) would have returned 'FooBundle'.
Now it returns 'SensioFooBundle'.

Why does it matter? Well, it makes template names and controller names easier to read:

Before:

    Template: Sensio\FooBundle:Bar:index.twig.html
    Controller: Sensio\FooBundle:Bar:indexAction

After

    Template: SensioFooBundle:Bar:index.twig.html
    Controller: SensioFooBundle:Bar:indexAction

NB: Even if the change seems simple enough, the implementation is not. As finding
the namespace from the bundle class name is not trivial

NB2: If you don't follow the bundle name best practices, this will probably
leads to unexpected behaviors.
2011-01-15 15:17:01 +01:00
Bulat Shakirzyanov
3a6f556189 [FrameworkBundle] registered FileSystem as a service, switched commands to use it 2011-01-14 08:23:38 +01:00
Johannes Schmitt
b4288459cc added ACL system to the Security Component 2010-12-31 09:25:53 +01:00
Henrik Bjørnskov
50cfd4a7bf [FrameworkBundle] Create the bundles directory before trying to symlink else it will throw an error 2010-12-08 08:12:16 +01:00
Ryan Weaver
7efb4630b8 [Command] Changing the InputOption::PARAMETER_* constants to InputOption::VALUE_* to more accurately reflect that these constants refer to the value or lack of value assigned to a particular option (e.g. --verbose or --em=doctrine).
To keep language consistent, three methods were changed in InputOption:

 * `InputOption::acceptParameter()` -> `InputOption::acceptValue()`
 * `InputOption::isParameterRequired()` -> InputOption::isValueRequired()`
 * `InputOption::isParameterOptional()` -> `InputOption::isValueOptional()`

The InputDefinition::asXml() method was also modified to update the `accept_value` and `is_value_required` attributes.
2010-11-27 19:56:27 +01:00
Ryan Weaver
757fd80b9b Improving the Command documentation for RouterApacheDumperCommand and adding the ability for the script_name to be specified as an option. 2010-11-26 21:15:49 +01:00
Ryan Weaver
5aa6ad28ae Updating RouteCollection::getRoutes() call to RouteCollection::getAll() in many places. 2010-11-26 14:43:12 +01:00
Fabien Potencier
60bbb8f380 [DependencyInjection] optimized compiled containers
* removed the __call() method in Container: it means that now, there is only
   one way to get a service: via the get() method;

 * removed the $shared variable in the dumped Container classes (we now use
   the $services variable from the parent class directly -- this is where we
   have a performance improvement);

 * optimized the PHP Dumper output.
2010-11-23 22:43:09 +01:00
Kris Wallsmith
f79e23ffb5 Removed all those spaces after @author that were bothering me so… 2010-10-18 16:55:41 +02:00
Fabien Potencier
aa1cb87f60 [FrameworkBundle] clarified exception message in InitBundleCommand.php (patch from mvrhov) 2010-10-08 10:17:17 +02:00
henrikbjorn
7ad510d6ef Added --symlink option to assets:install command 2010-10-08 09:55:57 +02:00
Fabien Potencier
69b538b632 [FrameworkBundle] removed the app:init command 2010-09-23 19:10:40 +02:00
Fabien Potencier
bf82cf42dd renamed Symfony\Components to Symfony\Component 2010-08-20 23:09:55 +02:00
Fabien Potencier
ee2ff39eaf removed @package and @subpackage annotations 2010-08-01 23:06:28 +02:00
Fabien Potencier
3f270f5faa [FrameworkBundle] added a skeleton for configuration in plain PHP 2010-07-20 16:34:40 +02:00
Fabien Potencier
256a71298c fixed phpdoc 2010-07-09 10:28:08 +02:00
Fabien Potencier
15d439809c renamed Symfony\Bundle\FoundationBundle to Symfony\Bundle\FrameworkBundle 2010-07-09 10:25:52 +02:00