symfony-components

Symfony ValidatorComponent > AnnotationMapping in FormComponent

喜欢而已 提交于 2021-01-28 07:26:46
问题 Im working on a project where I'm using some Symfony Components. My problem is how to make the Form Component's validation of Forms use AnnotationMapping to find the constraints. SetUp: global $loader; //composer - autoload AnnotationRegistry::registerLoader([$loader, 'loadClass']); $validator = Validation::createValidatorBuilder() ->enableAnnotationMapping() ->getValidator(); $formFactory = Forms::createFormFactoryBuilder() [...] ->addExtension(new ValidatorExtension($validator)) -

Can Goutte/Guzzle be forced into UTF-8 mode?

时光毁灭记忆、已成空白 提交于 2019-12-29 04:53:41
问题 I'm scraping from a UTF-8 site, using Goutte, which internally uses Guzzle. The site declares a meta tag of UTF-8, thus: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> However, the content type header is thus: Content-Type: text/html and not: Content-Type: text/html; charset=utf-8 Thus, when I scrape, Goutte does not spot that it is UTF-8, and grabs data incorrectly. The remote site is not under my control, so I can't fix the problem there! Here's a set of scripts to

Symfony config component and Doctrine dbal

喜欢而已 提交于 2019-12-25 07:46:54
问题 Via composer i installed doctrine dbal and symfony2 config component "require":{ "symfony/dependency-injection": "2.4.*", "symfony/filesystem": "2.4.*", "symfony/config": "2.4.*", "doctrine/dbal": "2.3.4" } I autoload them via require_once __DIR__ . '/vendor/autoload.php' Then code goes like this use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/app/config/')); $loader->load(

Symfony 2 Controller dependencies, extending ContainerAware

馋奶兔 提交于 2019-12-25 00:18:39
问题 Edit after digging into the symfony code, particularly the ControllerResolver, it seems what im trying to do actually isnt possible unless i subclass/implement ControllerResolverInterface myself. this is the following code which instantiates the controller passed from the route: protected function createController($controller) { if (false === strpos($controller, '::')) { throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller)); } list($class, $method) =

Doctrine standalone without cli-config.php

对着背影说爱祢 提交于 2019-12-21 02:50:06
问题 I want to integrate Doctrine ORM into my (non-Symfony) project. I already done this in another project and used the famous cli-config.php into the project root directory. But now, in my new project, I use the Symfony Console component and the Dependency Injection component (to reference services and commands, by tagging them). 1. I absolutely don't want to have a cli-config.php in the project root. How the Sf Doctrine Bundle do this? 2. Also (but it is less important), I would like to have

Symfony config component and service for Doctrine DBAL

烈酒焚心 提交于 2019-12-13 06:55:52
问题 This is a continuation of Symfony config component and Doctrine dbal I am trying to create service for doctrine now like this: <?php namespace Localhost\Service; use Doctrine\Common\ClassLoader; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; class Doctrine { public function __construct() { $doctrineLoader = new ClassLoader('Doctrine'); $doctrineLoader->register(); $doctrineConfig = new Configuration(); $doctrineParams = [ 'driver' => 'pdo_mysql', 'dbname' => 'levelup',

Run multiple Symfony console commands, from within a command

别来无恙 提交于 2019-12-10 18:51:45
问题 I have two commands defined in a Symfony console application, clean-redis-keys and clean-temp-files . I want to define a command clean that executes these two commands. How should I do this? 回答1: See the documentation on How to Call Other Commands: Calling a command from another one is straightforward: use Symfony\Component\Console\Input\ArrayInput; // ... protected function execute(InputInterface $input, OutputInterface $output) { $command = $this->getApplication()->find('demo:greet');

Goutte won't load an ASP SSL page

…衆ロ難τιáo~ 提交于 2019-12-08 15:38:22
问题 I am trying out Goutte, the PHP web crawler based on Symfony2 components. I've successfully retrieved Google in both plaintext and SSL forms. However, I've come across an ASP/SSL page that won't load. Here's my code: // Load a crawler/browser system require_once 'vendor/goutte/goutte.phar'; // Here's a demo of a page we want to parse $uri = '(removed)'; use Goutte\Client; $client = new Client(); $crawler = $client->request('GET', $uri); echo $crawler->text() . "\n"; Instead, the echo at the

Extending Symfony2 Controller Resolver

半城伤御伤魂 提交于 2019-12-07 12:31:03
问题 I am currently creating a bundle which can rename fooAction into fooAjaxAction if request is an Ajax Request. As the answer of that question says, I have to extend the controller resolver class. I have a ResourceNotFoundException if I change the controller_resolver.class in config.yml . but if I don't, I don't have any errors (but there is no override so this is not what I want) My questions are : how can i register my new controller resolver and use it ? I am right ? Wrong ? This is what I

Extending Symfony2 Controller Resolver

蹲街弑〆低调 提交于 2019-12-05 19:34:48
I am currently creating a bundle which can rename fooAction into fooAjaxAction if request is an Ajax Request. As the answer of that question says, I have to extend the controller resolver class. I have a ResourceNotFoundException if I change the controller_resolver.class in config.yml . but if I don't, I don't have any errors (but there is no override so this is not what I want) My questions are : how can i register my new controller resolver and use it ? I am right ? Wrong ? This is what I've done : You can find my Bundle for testing in packagist and download it via : composer require "