symfony1

How to document a Symfony based REST API (similar to enunciate's documentation capabilities)

旧巷老猫 提交于 2019-12-01 22:57:41
问题 If I have a REST based service written in the Symfony [symfony-project.org] framework (i.e. PHP), is there any decent tools/frameworks out there that will parse my code and generate API documentation? The Java based framework enunciate has documentation capabilities similar to what I need, you can view an example of this here: http://enunciate.codehaus.org/wannabecool/step1/index.html. I understand the premise of REST based services are supposed to be self evident, however I was after

Doctrine findBy* methods and fetch array

纵饮孤独 提交于 2019-12-01 21:58:36
What is the cleanest way of using the Doctrine findBy methods but getting an array returned and not objects. Doctrine::getTable('Table')->findOneById(x); That works but returns a doctrine object. I'd still like to be able to use the find methods but I know I can't add ->fetchArray() on the end. Anyone else had this problem? Try use toArray Doctrine::getTable('Table')->findOneById(x)->toArray(); You can specify the hydration mode when using magic finders, like so: Doctrine_Core::getTable('Table')->findOneById($x, Doctrine_Core::HYDRATE_ARRAY); Haim Evgi and DuoSRX's answers are correct, but

Validate a field depending on another field value in Symfony

元气小坏坏 提交于 2019-12-01 21:29:00
I have two related fields in a Symfony form: object_status and cryopreservation_method . The first one cannot be null and stores one of three possible choices: liquid , solid or cryopreserved . The second one should be only set if a record has its object_status set to 'cryopreserved' . Otherwise it is NULL . How can I check this in the server side (not with Javascript) before saving the form? I have tried to check for null or empty values in model, but with no luck. You have to create a conditional validator. This can be done using a sfValidatorCallback (easier than creating a new validator).

Format date in the indexSuccess.php

a 夏天 提交于 2019-12-01 21:03:44
I want to format the created_at field date from the original for something like 03.May.2011 to be shown in the indexSuccess.php and in the showSuccess.php Could you help me? thanks You can make in symfony in your indexSuccess.php and showSuccess.php instead of for example: <?php $value->getCreatedAt() ?> next: <?php echo date('d.M.Y', strtotime($value->getCreatedAt())) ?> You can use other formats. The format of some data absolutely not belongs into controller context - so please use use_helper("date"); echo format_date($myDate); from symfony's date helper in your template (showSuccess.php,

Update multiple columns with Doctrine in Symfony

二次信任 提交于 2019-12-01 17:47:40
I have to update multiple columns in Symfony, but I can nowhere find the solution... So, I'd like to do it in this way: $q = Doctrine_Query::create() ->update('WebusersTable q') ->set('q.login_name','?','John') ->where('q.webuser_id=?',1) ->execute(); OK, that works, but I have to do it with several columns. I tried something like this, but it doesn't work: $q = Doctrine_Query::create() ->update('WebusersTable q') ->set('q.login_name,q.name','?','kaka,pisa') ->where('q.webuser_id=?',1) ->execute(); Try: $q = Doctrine_Query::create() ->update('WebusersTable q') ->set('q.login_name', 'John') -

Update multiple columns with Doctrine in Symfony

无人久伴 提交于 2019-12-01 17:23:17
问题 I have to update multiple columns in Symfony, but I can nowhere find the solution... So, I'd like to do it in this way: $q = Doctrine_Query::create() ->update('WebusersTable q') ->set('q.login_name','?','John') ->where('q.webuser_id=?',1) ->execute(); OK, that works, but I have to do it with several columns. I tried something like this, but it doesn't work: $q = Doctrine_Query::create() ->update('WebusersTable q') ->set('q.login_name,q.name','?','kaka,pisa') ->where('q.webuser_id=?',1) -

Get #part in URL with PHP/Symfony

末鹿安然 提交于 2019-12-01 14:06:01
问题 I'm working with Symfony 1.2. I've a view with a list of objects. I can order them, filter them by category, or moving to the next page (there is pagination). Everything is done with AJAX, so I don't have to load all the page again. What I want to achieve is to have http://urltopage#page=1&order=title&cats=1,2 for example; so the new page is saved in the browser history, and he can paste it to another web. I haven't found a way to get the #part. I know that's only for the browser but I can't

Why does Doctrine say it can't find the PDO driver?

我的未来我决定 提交于 2019-12-01 14:00:09
问题 I tried Symfony 2 today and I tried to play a bit with Doctrine. But when I use the command php app/console doctrine:schema:create in the command line, it returns this error: [PDOException] could not find driver doctrine:schema:create [--dump-sql] [--em[="..."]] My php.ini file and phpinfo() cleary show that the PDO driver is loaded. I also created a little script in pure PHP to connect to my database using PDO and it worked fine. No error, so PDO is well installed and works. PHP and MySQL

Doctrine2 ManyToMany doesn't execute listener events

青春壹個敷衍的年華 提交于 2019-12-01 12:39:11
问题 I have the following db structure: User > UserRole < Role UserId UserRoleId RoleId Name UserId Name RoleId Active CreationDate And my doctrine2 classes are defined like this: /** * @var Roles * * @ORM\ManyToMany(targetEntity="SecRole") * @ORM\JoinTable(name="SEC_USER_ROLE", * joinColumns={@ORM\JoinColumn(name="SEC_USER_ID", referencedColumnName="SEC_USER_ID")}, * inverseJoinColumns={@ORM\JoinColumn(name="SEC_ROLE_ID", referencedColumnName="SEC_ROLE_ID")} * ) */ private $userRoles; public

Doctrine2 ManyToMany doesn't execute listener events

廉价感情. 提交于 2019-12-01 12:37:29
I have the following db structure: User > UserRole < Role UserId UserRoleId RoleId Name UserId Name RoleId Active CreationDate And my doctrine2 classes are defined like this: /** * @var Roles * * @ORM\ManyToMany(targetEntity="SecRole") * @ORM\JoinTable(name="SEC_USER_ROLE", * joinColumns={@ORM\JoinColumn(name="SEC_USER_ID", referencedColumnName="SEC_USER_ID")}, * inverseJoinColumns={@ORM\JoinColumn(name="SEC_ROLE_ID", referencedColumnName="SEC_ROLE_ID")} * ) */ private $userRoles; public function __construct() { parent::__construct(); $this->userRoles = new \Doctrine\Common\Collections