symfony-components

Generating a PHAR for a simple application

为君一笑 提交于 2019-12-04 07:42:30
问题 I'm experimenting in building CLI tools using the Symfony2 console library. I've got something basic working and now I want to package it as a phar. I've read a few examples but the ones I've seen are very simple (3 files, no namespaces, etc). In my src/ directory I have the following: Above src/ I have a console.php that I execute to run the app. I also have a vendors/ dir as I'm using composer to install dependencies. console.php is very simple: #!/usr/bin/env php <?php set_time_limit(0);

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

隐身守侯 提交于 2019-11-29 00:13:10
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 replicate the problem. First, the scraper: <?php require_once realpath(__DIR__ . '/..') . '/vendor/goutte

How to create custom event in symfony2

*爱你&永不变心* 提交于 2019-11-28 03:56:10
I want to create custom events called user_logged so that i can attach my listeners to those events. I want to execute few functions whenever user has logged in. Lusitanian Create a class which extends Symfony\Component\EventDispatcher\Event . Then, use the event dispatcher service to dispatch the event: $eventDispatcher = $container->get('event_dispatcher'); $eventDispatcher->dispatch('custom.event.identifier', $event); You can register your event listener service like so: tags: - { name: kernel.event_listener, event: custom.event.identifier, method: onCustomEvent } Vladimir Kovpak This

How to create custom event in symfony2

余生长醉 提交于 2019-11-27 00:14:08
问题 I want to create custom events called user_logged so that i can attach my listeners to those events. I want to execute few functions whenever user has logged in. 回答1: Create a class which extends Symfony\Component\EventDispatcher\Event . Then, use the event dispatcher service to dispatch the event: $eventDispatcher = $container->get('event_dispatcher'); $eventDispatcher->dispatch('custom.event.identifier', $event); You can register your event listener service like so: tags: - { name: kernel