I recently took the Symfony2 plunge and started working on a little fun side project (more on that later).
Anyway, this particular project involves sending out daily text messages using the rather awesome Twilio API so I decided to use a Symfony2 task for this. The documentation on how to actually add your own task is a bit sparse so I figured I’d share.
The process is actually pretty straight forward:
- In your bundle create a directory named “Command” (without the quotes).
- Create a file that extends ContainerAwareCommand
- Create a protected function configure – “protected function configure()” to allow you to configure the name of your task and add any options or arguments you might need.
- Create a protected function execute – “protected function execute(InputInterface $input, OutputInterface $output)” to actually do whatever needs to be done.
- Thats it! Now you can run app/console and you’ll see your task.
Here is the code for mine:
Symfony2 was released this past Thursday. This marks a huge advancement in the framework with tons of new features, better programming patterns, and much better performance. Symfony2 is now the most popular PHP project on GitHub and contributors are helping better it each day.
Since we are so excited for this release, we are going to take on one small free project for the person or company who submits the best idea and reason for their project. We’ll be picking the free project within one week of today. Shoot us an email with your project and reason you’d like it done for free.
Congrats to the entire Symfony2 team and we look forward to helping out with it!
Last week we launched RentPrefs a new take on renting an apartment. RentPrefs flips the process around by allowing renters to post their preferences and then allowing agents to match them with listings that fit their criteria.
Anyway, yesterday Xconomy did an awesome write up about them so definitely check it out. We also got a nice mention at the end there!
Recently we’ve launched a new site for a client called Purpose Beverages: http://trackyourimpact.com . We’ve received great feedback from users so far. The site uses a wide range of technologies. It is built on symfony and uses the Apostrophe CMS to manage the main parts of the site. It integrates with a SMS provider to allow you text into it to find out more about your purchase.
Tēvolution is a new brand of tea on the market that does good with each purchase. Every time someone buys it they done a specific amount(for example 25 cents) to a specific charity. In order to find out how large of a donation and what charity your bottle goes to you can actually text the code found on the bottle to the website, or you can login in on your phone browser or regular browser and enter the code. You will find out how much and to whom you just donated money to!
Right now Tēvolution is just coming to the market so keep your eyes peeled for it! It’s a great product that does good!
On a project I’m working on I came across the following problem: we had a email field that we needed to be unique in our system, but we also made sure that it matched a confirm email field. A snippet of our form looks like this:
When we submitted an email that was already in the system we got back two errors:
- Sorry! A user with that email address already exists.
For a while I thought is there some extra validator somewhere that I left on? Where is this invalid coming from? It ended up being due to the way the validators work. If a validator throws an error it doesn’t return that validator’s value. So by the time it gets to the sfValidatorSchemaCompare post validator the value of `email` is null and `confirm_email` has the value you input, thus the seemingly extra ‘Invalid’ message.
This can be fixed easily with a sfValidatorCallback instead of the sfValidatorSchemaCompare. Here is the fix:
This way if the email is blank it doesn’t both making sure that the `email` matches the `confirm_email`. You don’t need to worry about a person just passing two blank emails as the earlier validator(the sfValidatorEmail requires it to be there and valid).
If you are getting an extra validation error, check your postValidators and how the values get to them.