Giter Site home page Giter Site logo

symfony / symfony Goto Github PK

View Code? Open in Web Editor NEW
29.3K 1.1K 9.3K 268.7 MB

The Symfony PHP framework

Home Page: https://symfony.com

License: MIT License

Shell 0.03% PHP 97.84% HTML 0.06% CSS 0.18% JavaScript 0.10% Hack 0.01% Twig 1.79% Makefile 0.01%
framework php symfony symfony-bundle bundle php-framework hacktoberfest

symfony's Introduction

Symfony Logo

Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Symfony is used by thousands of web applications and most of the popular PHP projects.

Installation

Sponsor

Symfony 7.1 is backed by

Rector helps successful and growing companies to get the most of the code they already have. Including upgrading to the latest Symfony LTS. They deliver automated refactoring, reduce maintenance costs, speed up feature delivery, and transform legacy code into a strategic asset. They can handle the dirty work, so you can focus on the features.

Help Symfony by sponsoring its development!

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is led by the Symfony Core Team and supported by Symfony contributors.

symfony's People

Contributors

alexandre-daubois avatar chalasr avatar derrabus avatar dunglas avatar fabpot avatar fancyweb avatar heahdude avatar jakzal avatar javiereguiluz avatar jderusse avatar kriswallsmith avatar lyrixx avatar nicolas-grekas avatar nyholm avatar ogizanagi avatar oskarstark avatar pborreli avatar ro0nl avatar romainneutron avatar schmittjoh avatar seldaek avatar sroze avatar stof avatar tobion avatar vicb avatar weaverryan avatar webmozart 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

symfony's Issues

Unable to use 2 applications

I have set up two applications in my symfony project

  • src/Blog
  • src/Business

Every Application has his own kernel and cache class

  • app/BlogCache.php
  • app/BlogKernel.php
  • app/BusinessCache.php
  • app/BusinessKernel.php

and on each kernel I load only the bundles from the right application.
Each applications has a "MainBundle" but they are completely different. Only the name is the same.
But when I'm running a application (blog_dev.php) the other application does not work (business_dev.php).

Exception when running business_dev.php:
The "Blog\MainBundle\Controller\MainController" class does not belong to a registered bundle.

Symfony wants to run the MainBundle in "Blog" but I'm running the businness application :(

Using:
symfony2 beta1
routing with annotations (both applications have a route called "_homepage")

Log:
INFO [2011-05-04 14:23:30] request.INFO: Matched route "_homepage" (parameters: "_controller": "Blog\MainBundle\Controller\MainController::indexAction", "_route": "_homepage")
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\RequestListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\AsseticBundle\Listener\RequestListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Component\Security\Http\Firewall".
INFO [2011-05-04 14:23:30] request.INFO: Using controller "Blog\MainBundle\Controller\MainController::indexAction"
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ControllerAnnotationParser".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ParamConverterListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreException" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
ERROR [2011-05-04 14:23:30] request.ERROR: InvalidArgumentException: The "Blog\MainBundle\Controller\MainController" class does not belong to a registered bundle. (uncaught exception)
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\RequestListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\FrameworkBundle\Profiler\ProfilerListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Bundle\AsseticBundle\Listener\RequestListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreRequest" to listener "Symfony\Component\Security\Http\Firewall".
INFO [2011-05-04 14:23:30] request.INFO: Using controller "Symfony\Bundle\FrameworkBundle\Controller\ExceptionController::showAction"
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ControllerAnnotationParser".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\Controller\ParamConverterListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "Sensio\Bundle\FrameworkExtraBundle\View\AnnotationTemplateListener".
DEBUG [2011-05-04 14:23:30] event.DEBUG: Notified event "onCoreController" to listener "JMS\SecurityExtraBundle\Controller\ControllerListener".

[2.1] Refactor redirection logic after successful authentication

There are several problems with the current way:

  • default logic is hard-coded in AbstractAuthenticationListener (can not be modified without copy/paste)
  • there are problems with XHR/automatic background requests that might change the redirect path (this is hard to customize at the moment)

[Security] Session target_path not set when the incoming request has no session

Symfony\Component\Security\Http\Firewall\ExceptionListener only sets the target path when $request->hasSession() is true. This is the wrong behavior IMO as it checks if there is a previous session instead of checking if the session is activated in the project (which would be done by checking null !== $request->getSession().
I open the issue as @schmittjoh asked it on IRC saying he needs to check further about this.

Validator should not use Reflection to access properties

Validator using reflection to access properties is very bad. The validator should only be able to use public accessors to validator the object, otherwise it fiddles with the iternals of the object, breaking concerns

This happens to be a problem when validating unitizalized Doctrine proxies, which is not possible with Validator. We should change this ASAP.

[Form] impossible to disable the session

The form.csrf_provider service makes it impossible to disable the session as it requires it. But there is no way to disable the forms when we don't need it which means that it is now impossible to disable the session when nothing in the app requires it (a stateless webservice).

[Routing] URL doesn't match correct route due to escaped characters

Commas (",") and pluses ("+") are legal characters in path segment of the URL so I think Symfony\Component\Routing\Generator\UrlGenerator should not escape them.

Currently due to escaping:

  • correct route doesn't match when the "requirements" regex contains these characters (it's a bug)
  • bad looking url shows up in the user browser address bar
  • this can lead to duplicate content issues with search engines

Example use case:

route:

category_with_params:
    pattern:        /{category}/{params}/
    defaults:       { _controller: CompanyProjectBundle:Category:show }
    requirements:   { params: "[0-9a-z-]+(,[0-9a-z-]+)+(/[0-9a-z-]+(,[0-9a-z-]+)+)*" }

passed values:

category = laptops
params = brand,acer

expected path:

 /laptops/brand,acer/

generated path:

 /laptops/brand%2Cacer/

following generated path doesn't match "category_with_params" route and produces error (if no other matching routes exists):

No route found for "GET /laptops/brand%2Cacer/" 

Possible fix:

Replace 115 line in Symfony\Component\Routing\Generator\UrlGenerator:

                    $url = $token[1].str_replace('%2F', '/', urlencode($tparams[$token[3]])).$url;

with

                    $url = $token[1].str_replace(
                        array('%2F', '%2B', '%2C'),
                        array('/',   '+',   ','),
                        urlencode($tparams[$token[3]])
                    ).$url;

When redefining 'router.real' service, resource argument isn't populated

I have redefined the 'router.real' service so I can initialise it with more arguments, like so:

<services>
    <service id="router.real" class="%router.class%">
      <argument type="service" id="routing.loader" />
      <argument /> <!-- routing resource -->
      <argument type="collection">
          ...
      </argument>
    </service>
</services>

It works fine except for one problem, the 2nd 'resource' argument doesn't get populated in 'appDevDebugProjectContainer'.

The code where this is supposed to happen is in FrameworkExtension::registerTemplatingConfiguration. It seems like it should work fine, but it isn't...

Not a valid entity or mapped super class

Hi;

I have the following error when I try to insert a new record.

error:
Class App\TestBundle\Entity\User is not a valid entity or mapped super class.

code:

  orm:
         auto_generate_proxy_classes: %kernel.debug%
         auto_mapping: true

code:

    $em = $ this->get('doctrine')->getEntityManager();
    $em->persist($user);
    $em->flush();

Vague/incorrect error message when using non defined parameters in imported config resource

Today I tried to remove my parameters.ini file in favour of SetEnv.
This did not work because when you import another resource in your main configuration file and a parameter is found that is not defined an exception will be thrown which will result in the error message: "Cannot import resource '/path/to/your_config_file.yml'"
Unfortunately I can't look into it any more at the moment but I'll try to do some more thorough investigation where this happens.

[Form] errors are displayed at the wrong place when dealing with Collection type

When dealing with a Collection fields, errors for collection fields are rendered at the top of the form when prototyping the rendering with the form_widget() Twig function (see attached file).

Below is my code, I have a Person object who has a first name, a last name and 3 associated social links.

class Person
{
    /** @assert:NotBlank */
    public $firstName;

    /** @assert:NotBlank */
    public $lastName;

    /**
     * @assert:NotBlank
     * @assert:Collection(fields={
     *     0 = { @assert:NotBlank(), @assert:Url() },
     *     1 = { @assert:NotBlank(), @assert:Url() },
     *     2 = { @assert:NotBlank(), @assert:Url() }
     * })
     */
    public $links = array();
}

My PersonType class reads as follow:

namespace Sensio\DemoBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class PersonType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('firstName');
        $builder->add('lastName');
        $builder->add('links', 'collection', array(
           'type' => 'text',
        ));
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Sensio\DemoBundle\Entity\Person',
        );
    }
}

I have attached a screenshot of the bug at the following URI : http://trac.symfony-project.org/attachment/ticket/9722/form_errors.png

Segmentation fault (affected 2.0.0PR12 and 2.0.0BETA1)

Hello,
starting from version 2.0.0PR12 I get segmentation fault even for the demo app contributed with Symfony. The segmentation fault occurs only on Linux server (on Windows one there is no error). The version 2.0.0PR11 is working correctly.

Result of: strace /usr/local/lsws/fcgi-bin/php53 app.php
...
access("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", F_OK) = 0
lstat("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
lstat("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
open("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
fstat(5, {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
fstat(5, {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
mmap(NULL, 6410, PROT_READ, MAP_SHARED, 5, 0) = 0x2ba07369d000
open("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
mmap(NULL, 6410, PROT_READ, MAP_SHARED, 6, 0) = 0x2ba07369f000
munmap(0x2ba07369f000, 6410) = 0
close(6) = 0
fcntl(5, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(5, {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ba07369f000
lseek(5, 0, SEEK_CUR) = 0
lseek(5, 0, SEEK_SET) = 0
read(5, "<?php\n\n/**\n * appprodUrlGenerato"..., 4096) = 4096
lseek(5, 4096, SEEK_SET) = 4096
stat("/home/billing/domains/billing.d2.pl/public_html/billing/app/cache/prod/appprodUrlGenerator.php", {st_mode=S_IFREG|0666, st_size=6410, ...}) = 0
munmap(0x2ba07369d000, 6410) = 0
lseek(5, -4096, SEEK_CUR) = 0
close(5) = 0
munmap(0x2ba07369f000, 4096) = 0
access("/home/billing/domains/billing.d2.pl/public_html/billing/app/../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController::urlRedirectAction.php", F_OK) = -1 ENOENT (No such file or directory)
access("/home/billing/domains/billing.d2.pl/public_html/billing/app/../vendor/bundles/Symfony/Bundle/FrameworkBundle/Controller/RedirectController::urlRedirectAction.php", F_OK) = -1 ENOENT (No such file or directory)
access("/home/billing/domains/billing.d2.pl/public_html/billing/app/../vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController::urlRedirectAction.php", F_OK) = -1 ENOENT (No such file or directory)
access("/home/billing/domains/billing.d2.pl/public_html/billing/app/../vendor/bundles/Symfony/Bundle/FrameworkBundle/Controller/RedirectController::urlRedirectAction.php", F_OK) = -1 ENOENT (No such file or directory)
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

[Form] Form with readOnly field is always invalid

If field is marked as readOnly it will be always invalid because bind() doesn't set $this->bound to true and isValid() results in false.

may be this patch will be correct?

Index: ../vendor/symfony/src/Symfony/Component/Form/Form.php
===================================================================
@@ -392,6 +392,7 @@
     public function bind($clientData)
     {
         if ($this->readOnly) {
+            $this->bound = true;
             return;
         }

[MonologBridge] Non-existing logger constants

Hi all,

in vendor/symfony/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php in line 49 two constants are referenced, which do not exist (anymore) in vendor/monolog/src/Monolog/Logger.php:
Logger::CRITICAL, Logger::ALERT

Resulting in the following error when running an application using the master:
Fatal error: Undefined class constant 'CRITICAL' in /var/www/Symfony/vendor/symfony/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php

[2.1] Twig contextaware escaping

Rendering a template which outputs some JS currently requires to use {% autoescape true js %}

The naming convention of templates allows to know which is the format of the template. It would be useful to change the default context of the Twig auto-escaping feature according to it instead of always using html.

The option preferred_choice

Hi,

The option preferred_choices of the ChoiceType is never applied.

when I do:

     $ builder-> add ('test', 'choice', array (
         'choices' => array (
             '1 '=>' test1 ',
             '2 '=>' test2 ',
             '3 '=>' test3 ',
             '4 '=>' test4 ',
             '5 '=>' test5 '
         ),

         'preferred_choices' => array ('5 '=>' test5 ', '4' => 'test4')
     ));

I always have a list:
test1
test2

Outdated documentation

"Creating Pages in Symfony2" does not work with the release provided for download.

I have performed everything up to this line:
"Congratulations! After creating only a route and a controller, you already have a fully-functional page! If you've setup everything correctly, your application should greet you:"
http://localhost/app_dev.php/hello/Ryan

But I get the following error:
Unable to find controller "AcmeStudyBundle:Hello" - class "Acme\StudyBundle\Controller\HelloController" does not exist.
500 Internal Server Error - InvalidArgumentException

If I cannot create a Symfony2 page just by following the documentation, things become extremely difficult for a starter like me.

[2.1] Save full path in rendereded twig templates (instead of bundle:section:name)

Moved from trac.

I'm working on theming bundle. Now template MyBundle:Foo:bar.html.twig can be located in:

1) app/Resources/design/frontend/theme1/views/MyBundle/Foo/bar.html.twig
2) app/Resources/design/frontend/default/views/MyBundle/Foo/bar.html.twig
3) app/Resources/views/MyBundle/Foo/bar.html.twig
4) src/My/MyBundle/Resources/views/Foo/bar.html.twig

So when error in template occured I should know - in what same template.

For example. Template:

{{ 'create.post'|trans([], 'BlogBundle') a }}

Exception what I got:

Unexpected token "name" of value "a" ("end of print statement" expected) in "DemoBundle:Demo:hello.html.twig".

I've tryed to improve this by puting /absolute/path/to/template instead of template name to tokenizer. Diff 1:

--- a/code/vendors/twig/lib/Twig/Environment.php
+++ b/code/vendors/twig/lib/Twig/Environment.php
@@ -302,7 +302,8 @@
                 eval('?>'.$this->compileSource($this->loader->getSource($name), $name));
             } else {
                 if (!file_exists($cache) || ($this->isAutoReload() && !$this->loader->isFresh($name, filemtime($cache)))) {
-                    $this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $name));
+                    $this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $this->loader->getCacheKey($name)));
                 }

                 require_once $cache;

But got an error:

Twig_Error_Runtime: An exception has been thrown during the compilation of a template ("Template name "Z:home/dev/**/code/apps/app/Acme/DemoBundle/Resources/views/Demo/hello.html.twig" is not valid (format is "bundle:section:template.format.engine").") in "Z:\\home\\dev\\**\\code\\apps\\app\\Acme\\DemoBundle\/Resources\/views\/Demo\/hello.html.twig". in Z:\home\dev\**\code\vendors\twig\lib\Twig\Environment.php on line 469

And there is Diff 2 (looks like hack), wich solve this exception:

--- a/code/vendors/symfony/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
+++ b/code/vendors/symfony/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php
@@ -86,6 +86,12 @@
      */
     protected function findTemplate($name)
     {
+        if (false !== (array_search($name, $this->cache))) {
+            return $name;
+        }
+
         $tpl = $this->parser->parse($name);

         if (isset($this->cache[$key = $tpl->getSignature()])) {

Also I've added var_dump($name) to findTemplate function:

string 'FrameworkBundle:Exception:exception_full.html.twig' (length=50)

string 'FrameworkBundle:Exception:exception_full.html.twig' (length=50)

string 'FrameworkBundle:Exception:exception_full.html.twig' (length=50)

string 'FrameworkBundle:Exception:exception_full.html.twig' (length=50)

string 'Z:\home\dev\**\code\vendors\Symfony\src\Symfony\Bundle\FrameworkBundle/Resources/views/Exception/exception_full.html.twig' (length=122)

Why 4 times putted template in format Bundle:Section:name and on 5th time putted absolute path?

And I think that template name parser should store parsed templates instances. And maybe loader can store in cache path just by name, not by signature as now.

[Form] infinite loop (no exception thrown)

Imagine you have a OrderFormType class (OrderFormType.php) which contains OrderType field (among others), because AbstractType::getName() method returns 'order' for each item, it leads to an infinite loop, the problem is that we don't have any clue of that...

EntityChoiceField does not work with grouped choices

If you set the choices explicitly and nest the groups for support EntitychoiceList does not work anymore:

Exception: Entities passed to the choice field must be managed 

at EntityChoiceList ->getIdentifierValues (array(object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category), object(Category)))
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/vendor/symfony/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php at line 166  -+
at EntityChoiceList ->load ()
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/vendor/symfony/src/Symfony/Component/Form/Extension/Core/ChoiceList/ArrayChoiceList.php at line 34  -+
at ArrayChoiceList ->getChoices ()
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/vendor/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php at line 89  -+
at ChoiceType ->buildView (object(FormView), object(Form))
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/vendor/symfony/src/Symfony/Component/Form/Form.php at line 838  -+
at Form ->createView (object(FormView))
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/vendor/symfony/src/Symfony/Component/Form/Form.php at line 846  -+
at Form ->createView ()
in /var/www/eberlei/wsnetbeans/lsl-ff-db/trunk/src/HWS/PlatformBundle/Controller/ProfileController.php at line 102  -

Unable to set custom driver class for doctrine

My config:

doctrine:
    dbal:
        driver:   pdo_pgsql
        driver_class:   PgSqlBundle\Doctrine\DBAL\Driver\PDOPgSql\Driver
        host:     %database_host%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%

When I run:

php console doctrine:mapping:import MyBundle annotation

I got:

Fatal error: Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidTypeException' with message 'Invalid type for path "doctrine.dbal.connections.default.driverClass". Expected scalar, but got array.' in src\Symfony\Component\Config\Definition\ScalarNode.php:37
Stack trace:
#0 src\Symfony\Component\Config\Definition\BaseNode.php(190): Symfony\Component\Config\Definition\ScalarNode->validateType(Array)
#1 src\Symfony\Component\Config\Definition\ArrayNode.php(251): Symfony\Component\Config\Definition\BaseNode->normalize(Array)
#2 src\Symfony\Component\Config\Definition\BaseNode.php(193): Symfony\Component\Config\Definition\ArrayNode->normalizeValue(Array)
#3 src\Symfony\Component\Config\Definition\PrototypedArrayNode.php(212): Symfony\C in src\Symfony\Component\Config\Definition\ScalarNode.php on line 37

[2.1] Autowiring

Autowiring is a nice replacement for the removed interface injection. It is also mainly useful for controllers:

class MyController
{
    /**
     * @Autowire
     * @var Symfony\Component\HttpFoundation\Request
     */
    private $request;
}

The dependency injection container would automatically inject the "request" service into MyController::$request using property injection. The benefit is again less code to write (or configuration), faster development, and no container dependency in the controller. However, in contrast to method injection services would not be lazy-loaded.

[2.1] AuthenticationException enhancements

There are two enhancements which could be made to the AuthenticationException:

  1. add a getMessageKey(), getMessageData() which could be used by the translation component as the exception message itself cannot be safely displayed to the user
  2. change the signature of the constructor to match that of \Exception and pass $extraInformation via a setter

@lsmith77, do you still plan to work on this?

[Security] ACL: Ancestors relations regeneration problem

Hi all,

A couple of days ago I had an issue with the security component. Suddenly, after update some permissions I had this exception:

"Not all parent ids were populated. This implies an integrity problem."

I tried to track down the issue and finally I think I've found the problem. Method MutableAclProvider::regenerateAncestorRelations doesn't handle the update of the ancestors for the Acl's children. So, if some parent Acl was changed, it will not update relations between this new ancestor and the actual Acl's children. This causes the exception described before.

Looking at the master version of Symfony, the problem seems to be still there.

Thanks.

[ClassLoader] tests failed with line breaks

The ClassLoader class generate a \n for the line break, but the test file line breaks are \r\n (test on Windows 7)

not ok 236 - Failure: Symfony\Tests\Component\ClassLoader\ClassCollectionLoaderTest::testFixNamespaceDeclarations
 ---
 message: 'Failed asserting that two strings are equal.'
 severity: fail
 data:
   got:      "<?php\r\n\r\nnamespace Foo\n{\r\nclass Foo {}\r\n}\nnamespace   Bar \n{\r\nclass Foo {}\r\n}\nnamespace Foo\Bar\n{\r\nclass Foo {}\r\n}\nnamespace Foo\Bar\Bar\r\n{\r\n    class Foo {}\r\n}\r\nnamespace\r\n{\r\n    class Foo {}\r\n}"
   expected: "<?php\r\n\r\nnamespace Foo\r\n{\r\nclass Foo {}\r\n}\r\nnamespace   Bar \r\n{\r\nclass Foo {}\r\n}\r\nnamespace Foo\Bar\r\n{\r\nclass Foo {}\r\n}\r\nnamespace Foo\Bar\Bar\r\n{\r\n    class Foo {}\r\n}\r\nnamespace\r\n{\r\n    class Foo {}\r\n}"
 ...

same issue with

  • ApplicationTest::testHelp
  • ApplicationTest::testSetCatchExceptions
  • ApplicationTest::testAsText
  • ApplicationTest::testRenderException
  • ApplicationTest::testRun
  • CommandTest::testAsText
  • InputDefinitionTest::testAsText
  • GraphvizDumperTest::testDump
  • PhpDumperTest::testAddParameters
  • PhpDumperTest::testAddService
  • XmlDumperTest::testAddService
  • XmlDumperTest::testDumpAnonymousServices
  • XmlDumperTest::testDumpEntities
  • YamlDumperTest::testDump
  • YamlDumperTest::testAddParameters
  • YamlDumperTest::testAddService
  • YamlDumperTest::testAddService
  • ApacheMatcherDumperTest::testDump
  • PhpMatcherDumperTest::testDump
  • DumperTest::testInlineLevel

Attributes not rendered when customizing date form field

To reproduce:

  1. In config:
twig:
    form:
        resources: ['ResellerOrderBundle:Form:date_widget.html.twig']
  1. date_widget.html.twig:

    {% block date_widget %}
    {% spaceless %}
    {% if widget == 'text' %}
        {{ block('text_widget') }}
    {% else %}
        [div {{ block('attributes') }}]
            {{ date_pattern|replace({
                '{{ year }}': form_widget(form.year),
                '{{ month }}': form_widget(form.month),
                '{{ day }}': form_widget(form.day),
            })|raw }}
        [/div]
    {% endif %}
    {% endspaceless %}
    {% endblock date_widget %}
    
  2. In form template:

{{ form_row(form1.date_field, { 'attr': {'class': 'myclass'} }) }}

Result html does not render any attributes for [div] element. class="myclass" is expected. If you remove resources: ['ResellerOrderBundle:Form:date_widget.html.twig'] from config it will work, but I wanted to customize date to render only year and month, and I tought

{% block date_widget %}
{% spaceless %}
    {% if widget == 'text' %}
        {{ block('text_widget') }}
    {% else %}
        [div {{ block('attributes') }}]
            {{ date_pattern|replace({
                '{{ year }}': form_widget(form.year),
                '{{ month }}': form_widget(form.month),
                '{{ day }}': '',
            })|raw }}
        [/div]
    {% endif %}
{% endspaceless %}
{% endblock date_widget %}

will do the job.

[Routing] Problem with multiple routing file

With my routing configuration when I have more than one route in my last routing file (the third) it don't work

#app/config/routing.yml

_app_utilities:
    resource: "@AppUtilitiesBundle/Resources/config/routing.yml"
    prefix:   /app/utilities

#AppUtilitiesBundle/Resources/config/routing.yml

_app_utilities_brand:
    resource: "@AppUtilitiesBundle/Resources/config/routing/brand.yml"
    prefix:   /brand

#AppUtilitiesBundle/Resources/config/routing/brand.yml

_app_utilities_brand_index:
    ....
    ....

if I run this command php app/console router:debug I can see all my route but when I want to access it the route is not found

Error when mapping database enum field type

Error when mapping database

i execute : php app/console doctrine:mapping:import MyCoreBundle annotation

Returns:
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must be an instance of Swift_Mime_HeaderSet, none given

Code:

$message = \Swift_Message::newInstance()
            ->setSubject('Subject')
            ->setFrom('[email protected]')
            ->setTo('[email protected]')
            ->setBody($this->renderView('MyBundle:Default:email-body.txt.twig'));

        $this->get('mailer')->send($message);

Catchable fatal error: Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must be an instance of Swift_Mime_HeaderSet, none given in vendor/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php on line 30

This happends only in prod mode, in dev mode it works perfect.

[2.1] Method Injection

This type of injection is especially useful for code that is container aware (especially controllers).

<?php

abstract class MyController
{
    /**
     * @MethodInjection
     * @return Symfony\Component\HttpFoundation\Request
     */
    abstract function getRequest();
}

The abstract method would be implemented by the service container behind the scenes:

<?php

class ConcreteController extends MyController
{
    private $container;

    public function getRequest()
    {
        return $this->container->get('request');
    }
}

The benefit is less code to write, IDE autocompletion, and no container dependency in the abstract class.

[FrameworkBundle] Controller forward does not set route

Once inside a controller, $this->forward() is called, request.attributes.get('_route') is null.

This is because the duplicate is called with a non empty array for attributes (_controller) so the attributes are not totally cloned from the previous request.
And should the _route value take the old route? or the new one?

Symfony 1.4.11 - Typo on array property name in Pgsql.php

Symfony doctrine:build-schema reports errors during processing, while enumerating types for PostgreSQL - it complains that "typtype" is an unknown property. It's actually a typo in the code-base.

filepath: symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Pgsql.php line 194. In the code that enumerates types for PostgreSQL the property being tested is typo'd. Is "typtype" should be "type".

"if ($val['typtype'] == 'e'){" should be "if ($val['type'] == 'e'){"

[Translation][Session] Mixed responsibilities

This is an enhancement request i wrote from my experience building a translated page over the past few days.

I tried to implement a simple test portal using normal translation support. These were my two approaches:

  • Routing (/{_locale}/, /{_locale}/contact and so on)
  • Subdomain (de.exmaple.org/contact, en-us.example.org)

Both tries led to problems that made me worry.

  • Using translations enforces user sessions (to keep the locale), making session.auto_start: false impossible
  • Using {_locale} in routing makes the user session locale obsolete and useless (according to the book it just overwrites the session value)
  • Forced to use a session to handle application translations seems very limited and hacked.

My emphasis lies in the following quotes:

When a translation does not exist for a locale, the translator first tries
to find the translation for the language (fr if the locale is fr_FR for instance).
If this also fails, it looks for a translation using the fallback locale.
For example, http://www.example.com/contact could show content
in English for one user and French for another user. Unfortunately,
this violates a fundamental rule of the Web: that a particular URL returns
the same resource regardless of the user.
A better policy is to include the locale in the URL.

This is the point where the mess begins. Why should the user session be responsible to handle translations in this context?
Why should a fixed routing /{_locale}/ change anything on the users locale? He still speaks german and dislikes Euro even when browsing amazon.com.

The last quote shifts the responsibilities which could indicate that they are already in the wrong place.

My first approach to a solution would be the following ideas:

  • Decouple the user session from the translation support
  • Make translator.fallback the only way to influence default translation decisions
  • Remove the conenction between session.default_locale and the translation support
  • Make a new session translator directive a optional feature, injecting its possible value into the translation decision if needed. This would be the way to mimic the current implementation and get messy again
  • Make the request or routing (unsure) responsible for the requested and valid application locale

Features or fixes that could benefit from this:

  • Sessionless translated sites
  • Translatable routing (/en/contact and /de/kontakt) through /{_locale}/{trans:contact} as the enforced locale already defines into which language something should be translated
  • Domain/Subdomains could inject a language/locale to the translator (there is no way i can imagine that makes this dead simple without sessions... or even with)

Currently the books page reads like a workaround on a misconception about user locales, site translations and how to force all this together in the only possible way.

Still figuring out Symfony2 so maybe this is a misinterpretation.

[Firewall] No routing and locale support

Simple use-case:

#app/config/routing.yml

languageselector:
    pattern:      /

frontpage:
    pattern:      /{_locale}
    requirements: { _locale: en|fr|de, _scheme: http }

and

#app/config/security.yml
    firewalls:
        public:
           ...
            form_login:
                check_path: ?
                login_path: ?
                default_target_path: ?
            logout:
                path: ?
                target: ?

The backrouting is very limited. Neither will work for the ? placeholder: /{_locale}, frontpage, /{_locale}/login.
I'm new to Symfony maybe im missing something but my general understanding from the docs was that routing is the main component that all other should rely on. This seems like a serious limitation for localized sites as I need to route the user through the languageselector route to get him back to the frontpage (or any localized page).

Templates relative to bundle location

according to current documentation https://github.com/symfony/symfony-docs/blob/master/book/templating.rst,
the section "Template Naming and Locations" says: bundle:controller:template is the syntax for template naming.

-using the full syntax the template is relative to bundle location (AcmeBundle::index.html.twig)
-omitting bundle and controller, the template results relative to app dir. (::index.html.twig)

Usually, 90% of views are relative tho bundle location, so can be useful add a syntax for templates relative to bundle location.

Something similar to self::index.html.twig or .::index.html.twig (using self or ".").

This feature can avoid redundant code (the bundle name repeated foreach controller action view rendering)
May be interesting?

(thanks, sorry for my english)

[AsseticBundle] assetic:dump not dumping all assets

I have an issue with the command assetic:dump. I have two templates (say index.html.twig and home.html.twig) that share the same javascript file. When I use assetic:dump to dump the assets on disk, only one file is outputted instead of two as expected. Here's the code of the two templates:

index.html.twig

{% extends 'AcmeDemoBundle::layout.html.twig' %}

{% block content %}
    {% javascripts output = 'bundles/acme/js/index.js'
        '@AcmeDemoBundle/Resources/public/js/shared.js' %}
        <div><p><a href='{{ asset_url }}'>{{ asset_url }}</a></p></div>
    {% endjavascripts %}
{% endblock %}

home.html.twig

{% extends 'AcmeDemoBundle::layout.html.twig' %}

{% block content %}
    {% javascripts output = 'bundles/acme/js/home.js'
        '@AcmeDemoBundle/Resources/public/js/shared.js' %}
        <div><p><a href='{{ asset_url }}'>{{ asset_url }}</a></p></div>
    {% endjavascripts %}
{% endblock %}

However, if the set of files is different, then two files are outputted:

    {% javascripts output = 'bundles/acme/js/index.js'
        '@AcmeDemoBundle/Resources/public/js/shared.js'
        '@AcmeDemoBundle/Resources/public/js/specific.js' %}

Another thing odd I noticed is when I change the set of files (here shared.js and specific.js), I need to clear my cache before running assetic:dump for the changes to take effect. Is this suppose to be a correct behavior?

Here my assetic configuration in config.yml:

assetic:
    debug:          false
    use_controller: false

The assetic configurations (in config_dev.yml and routing_dev.yml) for my development environment are disabled (commented out). I tested this on Symfony2 Beta1, Windows 7, PHP 5.3.5 and Assetic shipped with Symfony2 Beta1.

[Form][Validation] impossible to disable the validator

The FrameworkBundle configuration allows to disable the validation. This used to work well but it is now broken with the following error: The service "form.type_guesser.validator" has a dependency on a non-existent service "validator.mapping.class_metadata_factory".
The validator is mandatory when using forms but it seems now to be mandatory even when not using them.

[Routing] Multiple level of prefix don't work anymore

I just updated from PR12 to the current master and I have an issue with the routing: multiple level of importation using prefixes does not work anymore. The cache file look like this:

if (0 === strpos($pathinfo, '/jeux')) {
        if (0 === strpos($pathinfo, '/preview')) {
            // game_preview_quiz_show
            if (0 === strpos($pathinfo, '/jeux/preview/qcm') && preg_match('#^/jeux/preview/qcm/(?P<id>\d+)$#x', $pathinfo, $matches)) {
                if ($this->context->getMethod() != 'get') {
                    $allow[] = 'get';
                    goto not_game_preview_quiz_show;
                }
                return array_merge($this->mergeDefaults($matches, array (  '_controller' => 'Tolkiendil\\GameBundle\\Controller\\PreviewController::quizAction',)), array('_route' => 'game_preview_quiz_show'));
            }
            not_game_preview_quiz_show:

    }

The second line should be if (0 === strpos($pathinfo, '/jeux/preview')) {

[FORM] bind erase data

in form.php

        foreach ($this->children as $name => $child) {
            if (!isset($clientData[$name])) {
                $clientData[$name] = null;
            }
        }

If the form request not have every fields of the Entity the var become Null and we cannot persist (or loose informations) :

    $form = $this->get('form.factory')->create(new FormManagerConfigLocalized(),$objectEntity);

    $request = $this->get('request');
    if ($request->getMethod() == 'POST') {
        $form->bindRequest($request);
        if ($form->isValid($form)) {
            $em->persist($objectEntity);
            $em->flush();
        }
    }

[Form] Logic error in FormView::getIterator()

public function getIterator()
{
    if (isset($this->children)) {
        $this->rendered = true;

        return new \ArrayIterator($this->children);
    }

    return new \ArrayIterator(array());
}

The first test isset($this->children) will always return true.

Exception: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (1024)

Error:

Exception: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (1024) in  vendor/symfony/src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php on line 396 

Generally, I don't like the idea of using exceptions for flow control, and that's what is done here

try {
            $this->dateTimeZone = new \DateTimeZone($timeZoneId);
        } catch (\Exception $e) {
            $this->dateTimeZone = new \DateTimeZone('UTC');
        }

In DateType::buildForm \DateTimeZone::UTC is passed as time zone ID, and therefore an error occurs in locale.

In dev mode whole page is flooded with exception traces and warnings "Cannot modify header information - headers already sent".

Don't you think this should be fixed?

[Form] Requirement for Intl extension

The form component still has some requirements for the Intl extension as it is calling "intl_is_failure" in Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer and Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer.

Cannot get Doctrine entity manager or other services from custom routing

I'm porting a routing component from sf1 which requires db access. I'm having issues retrieving an entity manager instance from the generator and matcher classes. Symfony seems to be like this by design, which makes it very hard to extend some of the core features in any serious way.

Is there a workaround for this?

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.