Author Archives: Ruben Vincenten
Using bower for your composer projects
If you are developing a project, and you just want to have your client side scripts and stylesheets being updated automatically, add the following to composer.json:
{ "require": { // requirements here }, "scripts": { "post-update-cmd": [ "bower update" ] } }
Offcourse, you do need to make sure you actually have bower and composer installed!
Manage VERSION, CHANGES and git tags with a bash script
Preventing RewriteBase - Deploy websites and apps on different locations
So I found a topic on stackexchange (for which unfortunately I can not find the link anymore) that had a question if it was possible to set up RewriteRules for sites in subdirectories. I found this to be an interesting topic, since I deal a lot with those kind of sites.
Continue reading “Preventing RewriteBase - Deploy websites and apps on different locations” »
wp_page_menu forward compatibility with wp_nav_menu
You’ve styled your wordpress menu’s like the following:
#site-navigation li.menu-item-has-children { position: relative; } #site-navigation ul.sub-menu { position: absolute; min-width: 100%; top: 100%; left: 0; } /* etcetera etcetera */
However, when you’ve not set a menu for your menu locations, dropdowns no longer work, current menu items are no longer styled, etcetera, etcetera. How do we fix it?
Continue reading “wp_page_menu forward compatibility with wp_nav_menu” »
Generating ORM classes (doctrine, propel, zend db table) with MySQL workbench and schema exporter
Just a short post to let you know that I just found this awesome github project that I need to checkout some day, to generate model files automatically.
https://github.com/johmue/mysql-workbench-schema-exporter
- In doctrine/propel you generate ORM classes based on annotations, yaml or xml.
- In MySQL workbench, you can completely design a schema file and “migrate” the schema file against a database. The changes will be detected and will be written in an update script.
With these two tools, developing with database entities should be a breeze.
WordPress gravatar / avatar bug: comment email instead of admin email
The following can happen:
- You make a site for a customer
- You insert some comments that your customer provides.
- Gravatar uses the admin email instead of the comment author email.
How do you get a gravatar image for the comment email instead of the author email?
You need to write a filter function. the get_avatar
filter passes the img code as first param, and the id of the author(you) or an emailaddress as the second.
Continue reading “WordPress gravatar / avatar bug: comment email instead of admin email” »
Apache fallbacks without mod_rewrite
Just found out this awesomeness. In Apache 2.2.16 and higher, you can completely forget about mod_rewrite rules for your front controller:
RewriteRule ^.*$ index.php?url=$0 [L,QSA])
Apache has a tag called FallbackResource
:
FallbackResource /index.php
Woopdeedoo! Less code, more profit.
PAC files: No more editing your hosts file, use a proxy script!
In this article I will explain to you how to automagically map any domain names to your local testing/development server (For example, you are running, WAMP, XAMPP, or MAMP).
Continue reading “PAC files: No more editing your hosts file, use a proxy script!” »
ModRewrite Shenanigans
So I am trying to figure out how to set up a router that can set up site hyperlinks that work with a mod_rewrite situation. I really like PATH_INFO
for this as I can use this for apps in subdirs (testing environment for example). This way, you can use http://domain.com/controller/action/1
and still have the fallback url working: http://domain.com/index.php/controller/action/1
.
If you place the following code in your htaccess, you can enjoy this technique.
#Force Path info in PHP, gets overridden in RewriteRule.
SetEnvIf Request_URI "^/?" PATH_INFO=/
# Mod Rewrite is off by default.
SetEnv MOD_REWRITE 0
<IfModule mod_rewrite.c>
# Update environment variable with some info.
SetEnv MOD_REWRITE 1
RewriteEngine On
# Webroot directory relative to index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?(robots\.txt|favicon\.ico|index.php)$
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
How does it work?
This way, you can use the following logic in your code to generate a correct url.
- Construct a variable to prepend:
- Take the directory name of the SCRIPT_NAME environment variable if the MOD_REWRITE environment variable is 1…
- … Or take just the SCRIPT_NAME environment variable.
- Add a trailing slash if missing.
- Add the url to a page you want or use the PATH_INFO environment variable for the current page (canonical links).