Archive for category PHP
PHP CMS Framework
Posted by martiendejong in Martien, News, PHP, Programming on June 2, 2011
I am working on creating a PHP CMS framework for myself and others. I know that there are many CMS frameworks already, but the ones I found are very complex and/or difficult to use. In addition, I am a fan of very clean code, that’s why I like to give it a try myself.
The goal is to create something that is extremely easy to use from a programmer, designer, system administrator or end-user perspective.
It should also be as flexbile as possible and synchronize easily with other frameworks.
What I have so far is an idea about the general structure of the project. Feel free to comment criticism.
- application
- kernel
- App.php
- Module.php
- Router.php
- __autoload.php
- functions.php
- modules
- start.php
- install
- start.php
- boot
- start.php
- www
- config.php
- start.php
- public_html
- .htaccess
- start.php
$app = new App(‘path/to/application’);
App->Start();
Array to object conversion in PHP
Posted by martiendejong in PHP, Programming on June 1, 2011
I just wrote this simple function to convert arrays to objects in PHP.
For me it is convenient to have such a function at hand for quickly generating objects.
/*
* @param $class the name of the class that should be instantiated
* @param $array the array with key=>value combinations that is used to create the object
* @return an object of type $class with the values from $array
*/
function a2o( $class, $array ) { return array2object( $class, $array ); }
function array2object( $class, $array )
{
$obj = new $class( );
foreach($array as $key => $value)
$obj->$key = $value;
return $obj;
}
The question mark in URLs
Posted by martiendejong in PHP, Programming on March 21, 2010
When constructing an url via a plugin, you cannot always know at which position the ? will come.
A simple htaccess rule can be used to strip off the first ?:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)&(.*) $1?stripquestionmark=true&($2) [L,NS] [L]