The WordPress Shortcode API allows you to render template blocks by simply calling the shortcode in a post or page. Template blocks can be a part of a theme or a plugin, but may be included by entering a shortcode for the template when creating a post/page in wp-admin, allowing users to easily include content. more…
Creating a Crawler in Symfony 2 Using the DomCrawler and Client
There have been a few times where I have needed to crawl a Symfony 2 site to index pages and execute code so I built a crawler console command designed using the Symfony 2 DomCrawler and Client. This is a fun alternative to using curl, and the client offers plenty of browser-like features that come in handy more…
How to View Text that is Run Through the Symfony 2 Translator by Highlighting Translations
The Symfony 2 translator does a great job at translating text but there is not a great way to quickly see what text in a project is translated, especially when it could be translated by Symfony internally, in a model file, in a controller, in a twig template, etc. Given all of the different options, how could you quickly confirm text is running through the translator, and running through the translator only one time, so you don’t end up double translating text. more…
Create a Custom Form Field Type in Symfony 2
The form builder in Symfony 2 is very flexible and has dozens of field options, but there will inevitably come a time when you need to create your own custom form field. The Symfony Cookbook has a great article on how to create a custom form field type and use it in your project. more…
Override Symfony 2 Form Element Twig Template
It is possible to change the way a form element is rendered in a Symfony 2 project by overriding the Twig template. You can do this on a per-form basis by including the form element’s block right in your view, or you can make the change application-wide. more…
Create an Authentication Listener in Symfony 2
It is possible to subscribe to many events in Symfony 2, and login events are no different. You may want to have an authentication listener that increments a user’s failed login attempts so an account can be locked or you may want to set the last login date for a user on a successful login. more…
12 Plugins That Make Sublime Text 2 the Best Code Editor for PHP Development
Sublime Text 2 is a fantastic code editor but out of the box is pretty limited in PHP IDE functionality. There are many plugins available for Sublime Text 2 that make it more of an IDE and in my opinion, the best editor available for PHP development. more…
Change the WordPress Author Link Base from ‘author’ to a Custom Name
Changing the base of author links in the url
In WordPress the author’s page is usually linked to at the url
Change the Symfony 2 Validator Translation Domain and File Path
By default, the translation domain for the Symfony 2 validator is ‘validators’ and the translations are stored in the resources/translations/validators.<locale>.xliff files. In some applications it might be nice to use the same translation file as the rest of the site translations for validation messages, rather than using a separate validation translation file. Symfony makes this easy by setting a single parameter.