Tag Archives: php

Few PHP 5.3 Presentations & RegX Cheat Sheet I Liked

I happen to find these while reading/surfing, so thought of putting it here …. I would be adding more to this post ….
[pdf http://www.decentmind.com/wp-content/uploads/2011/01/php5.3.pdf ]
regular-expressions-cheat-sheet-v2.pdf
Courtesy: [http://ebookchoice.net/php-5-3-awesome.html#]

-deepak Continue reading

Posted in Technology, cheatsheet, php | Tagged , , , | View Comments

Multiple domains on symfony project

This post is about developing a symfony project that provides multiple applications that are reachable on multiple top level domains. In our case, the symfony applications “UMTS Netzabdeckung” and “Flatrates Vergleich” share the same backend (models, data, etc.) but each site is a standalone application and has a dedicated top level domain.

Create two applications

The first step is to create two applications. Run

symfony generate:app site1
symfony generate:app site2

in your console and change the default actions, routing, etc. Same thing as usual.

Edit .htaccess

The next step is quite simple: Open your .htaccess file in /sf_project_dir/web and insert your second application to the .htaccess file (BEFORE the default RewriteRule)

RewriteCond %{HTTP_HOST} secondhost.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ site2.php [QSA,L]

That’s all!

That’s all to get it working. Each request to your second domain will be redirected to the according application. A drawback is, that your “frontend” application is still reachable on your second domain if you type in the script name directly. Since I’m not an htaccess expert, I just added some php code to my index.php:

if($_SERVER['SERVER_NAME'] != ‘www.flatratesvergleich.de’) {
header(‘Location: http://www.flatratesvergleich.de’ . $_SERVER['REQUEST_URI']);
die;
} Continue reading

Posted in General, Symfony | Tagged , , , , | View Comments

How to Create Your First WordPress Plugin

Today I just explained the concept a wordpress plugin to one fo my mate @ workplace. So thought of documenting it here for my own reference. Example explained here is different than what i explained to my friend.

A WordPress plugin is simply one or more PHP files that adhere to certain rules and conventions. All you need to understand and complete this post is a basic understanding of PHP programming.

Aim of this post is to explain the concept of creating a Wordpress Plugin i.e. to explain the process for newbies.
Lets create a plugin which simply displays the most commented 5 posts.

Plugin Folder Structure

../wp-cpntent/plugin/your_plugin

Now we will create a folder in Wordpress Plugin directory say “most_commented_post” i.e.

../wp-cpntent/plugin/most_comments_on_post

Activating/Deactivating the Plugin
In order for wordpress to activate/deactivate we need to add PHP comments to main file of the plugin. Means we will create a file named “most_commented_post.php”

../wp-cpntent/plugin/most_comments_on_post/most_commented_post.p Continue reading

Posted in Technology, Wordpress | Tagged , , , , | View Comments

Symfony: get the working environment(Development or Production)

While developing an application in Symfony , You might want to run some part of your code in development environment and other part in production environment. In such situation you can use sfConfig::get class to get the environment in which … Continue reading

Posted in Symfony, Technology | Tagged , , , , | View Comments