Categories
Blog Tips

How to extract attributes from an HTML string in PHP (without using RegEx)

Say you have an <a>, <link> or other HTML element and you need to extract its href (or other) attribute. You can extract those values using DOMDocument quite easily: Link to Repl.it PHP: DOMDocument

Categories
Tips

How to iterate a list in batches using Twig (or plain PHP)

Recently I had to loop through a series of elements in a WordPress template (thanks Timber), which happened to be using Bootstrap. If you ever used Bootstrap, you are familiar with the following markup: The problem here is very common. You have to: Loop every 3/4/n items. Insert a separator or whatever every 3/4/n items.

Categories
Apps/Tools

Build a simple website with Silex

Update: Silex has been deprecated in June 2018 in favor of Symfony. I love static* websites. They’re usually faster to develop, smaller, require no database or backend and are faster to load. Of course they require more work to maintain and tweak at first, but if you’re a developer, these things should be pretty entertaining or at […]

Categories
Blog

Laravel Homestead: multiple projects, one VM

Vagrant is great to isolate a development environment inside a VM. However, after a while you can find you have a bunch of heavy VMs that share the same characteristics, each one for a simple PHP project. Enter Laravel Homestead In these cases, you can safely use Laravel Homestead. Homestead is a Vagrant box pre-configured with an Nginx web […]

Categories
Tips

Run a simple HTTP server with one command line

Recently someone told me this great and simple trick on how to run an HTTP web server with just one command line. This is useful for a million things, but I use it for prototyping and avoid same-origin policy in Chrome.

Categories
Blog

Doctrine 2

Últimamente estuve trabajando bastante con CodeIgniter en conjunto con el ORM de Doctrine 1.2 para simplificar el acceso a datos y dar más poder que el Active Record que implementa el framework. Hoy me topé con una presentación muy interesante de lo que traerá la versión 2, que aprovecha todo el potencial de PHP 5.3. Una […]

Categories
Blog

Nace CodeIgniter Reactor

EllisLab, Inc., la empresa responsable y creadora de el framework PHP CodeIgniter anunció que a partir de el año que viene el desarrollo del mismo se dividirá en dos ramas: CodeIgniter Core será mantenida por la empresa e incorporará cambios de la segunda rama, a un ritmo más lento, para adaptarse al ambiente empresarial. CodeIgniter […]

Categories
Apps/Tools Blog

Friendly URLs in XAMPP

Update: this post is pretty old. I recommend you give Local a try. A very common requirement for today’s apps is having “friendly” or clean URLs. We can achieve that easily in XAMPP, following these steps: First, enable Apache’s mod_rewrite module: Edit httpd.conf file under [xampp-install-directory]/apache/conf. On Windows, that’s typically C:\xampp. Uncomment:#LoadModule rewrite_module modules/mod_rewrite.so So it stays:LoadModule rewrite_module […]