symfony1

How to format a getUpdatedAt() kind of date in Symfony?

孤人 提交于 2019-12-03 14:29:29
I'd like to change the formatting of a date in Symfony 1.4 The default one being: <?php echo $question->getUpdatedAt(); // Returns 2010-01-26 16:23:53 ?> I'd like my date to be formatted like so: 26/01/2010 - 16h23 I tried using the format_date helper DateHelper class. Unfortunately the API is rather empty (something really needs to be done about it.) Browsing the helper's source code, I found that a second argument, format, can be passed. I assumed it was using the same syntax as PHP's date function . But here's what it outputs (same example as above): <?php sfContext::getInstance()-

Symfony forms: how to change default widget for form generation

◇◆丶佛笑我妖孽 提交于 2019-12-03 13:56:43
问题 I'm using a custom Widget for date fields, and I want to use it in all my forms. The problem is that symfony uses the default sfWidgetFormDate. What I want is to change this default widget in order to generate forms with my custom Widget. I don't want to change by hand all the forms generated. The only approach I have found is the trik of modify BaseFormDoctrine.php: public function setup() { foreach($this->getWidgetSchema()->getFields() as $name=>$widget) { if($widget instanceof

combine symfony1 and Symfony2 projects

筅森魡賤 提交于 2019-12-03 13:54:46
问题 There is an existing website developed in symfony1.0 (propel as ORM). I have developed a module in Symfony2 (Doctrine2 as ORM) for the website. Both have authentication. New module should use members from existing database. Session between them should not be broken. What steps should I follow? How to handle this? 回答1: I think you should create a custom user provider in your Symfony2 project to be able to share the users between two projects (but first check if you could use the doctrine user

Best Step by Step tutorial for Symfony - (I am running PHP on Windows) [closed]

纵然是瞬间 提交于 2019-12-03 13:22:48
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have tried to follow the symfony tutorial here: http://www.symfony-project.org/book/1_2/03-Running-Symfony It's incoherent : It says to download the sandbox but the rest of the tutorial seems for the non-sandbox version. It's not a step by step as it seems and I can't get the same result. This is really

Symfony (PHP framework) and MongoDB ( or any json-based database) [closed]

帅比萌擦擦* 提交于 2019-12-03 12:43:22
I was wondering if its possible to use a json-based schema-free, document-based database like Mongodb or Couchdb on a symfony project like its used for ruby-on-rails websites? And if yes, how can it be done? There is a DoctrineMongoDBBundle for use with Symfony 2 You might get some help from the MongoDB PHP Language Center . There are links to several PHP libraries for MongoDB, including a centralized logger for symfony applications. Nate Abele You can also check out http://li3.me/ , the only full-stack PHP framework with fully-integrated support for MongoDB (and CouchDB). Try building your

Doctrine: Multiple (whereIn OR whereIn) query?

别等时光非礼了梦想. 提交于 2019-12-03 11:50:40
问题 I'm having trouble crafting a fairly simple query with Doctrine... I have two arrays ($countries, $cities) and I need to check whether database record values would match any inside either. I'm looking for something like: ->whereIn('country', 'city', $countries, $cities) ... with 'country' being a WHERE IN for $countries and 'city' being a WHERE IN for $city. I could separate the two out but the needed query has lots of other conditions so that's not possible. The resulting SQL I'm after would

How to 'validate' a Symfony form in steps - instead of calling $form->isValid()

一个人想着一个人 提交于 2019-12-03 10:20:43
问题 I am using Symfony 1.3.6 on Ubuntu. I have a form with a lot of fields on it - rather than showing all the fields in one go (which may intimidate the user), I want to break up the form into stages, so that a user can fill in only the fields displayed, at each step/stage (kinda like a wizard). In order to do that, I need to write custom methods for the form, e.g.: validateStep1(); validateStep2(); ... validate StepN(); Where in each of the functions above, I only validate a subset of the

what's the proper way to use Symfony's EventDispatcher component?

Deadly 提交于 2019-12-03 09:45:11
问题 I'd like to promote loose coupling in my PHP code, by making certain classes observable. Symfony's EventDispatcher component looks promising, as does the SPL SplObserver/SplSubject pair of classes. What's the best way to do this? I can see a couple of different possibilities: (1) Inject an EventDispatcher instance into each observable class (keeping track of a global EventDispatcher instance): class Foo { public function __construct($dispatcher) { $this->dispatcher = $dispatcher; } public

PHP Warning “Warning: ob_start(): function '' not found or invalid function name” in Symfony 1?

我的未来我决定 提交于 2019-12-03 09:41:11
Why am I getting: Warning: ob_start(): function '' not found or invalid function name in /symfony-1.3\lib\config\sfApplicationConfiguration.class.php on line 155 This occurs with Symfony 1.x projects. I am using Apache 2.2 and PHP 5.4.1. The mentioned line has: ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); Try using a null value instead of the empty string. ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null); Roy Orpiano - ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); + ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null); This was

Doctrine_Core::getTable()->findAll() how to specify order?

岁酱吖の 提交于 2019-12-03 09:39:42
When using a Doctrine_Table object, is it possible to specify the order of the returned collection when using findAll() or findByWhatever() ? In the doc's I see some stuff about getOrderByStatement() and processOrderBy() but it isn't clear on how to use them... You can also leave the first array blank $em->getRepository('BackendDestinyBundle:Destiny')->findBy(array(), array('title'=>'asc')); You can in fact specify a default order by in your schema: Foo: columns: ... options: orderBy: bar DESC Note that when you want to specify a different order, you can still create a query and override the