DooPHP - fastest MVC based PHP framework

Learn More

The Official Blog of DooPHP

News, Updates, Tips & Tricks for DooPHP

Subscribe to Blog

Subscribe to the official blog of DooPHP framework.

Slides for PHP Malaysia Meetup 2011 2011-02-22 15:30:13

Slides for PHP Malaysia Meetup 2011

For those who are looking for the presentation slides for DooPHP used in PHP Malaysia Meetup 2011. You can also click on the link to download the PDF or android apk


Published under: Tips & Tricks Share/Save/Bookmark

Extending DooPHP Framework2009-09-12 21:13:22

Extending DooPHP Framework

If you would like to extend the framework, you can write your own class that extends the framework classes.

For instance, you might want to extend the DooValidator. You can write your own validator class in protected/class

Doo::loadHelper('DooValidator');

classs MyValidator extends DooValidator{
     //..??your extended code..
}

And then you can use your extended class in controller:

Doo::loadClass('MyValidator');

Read more tips & tricks at the forum


Published under: Tips & Tricks Share/Save/Bookmark

Database Replication (Master-slave) Support in DooPHP2009-08-21 03:41:25

Database Replication (Master-slave) Support in DooPHP

Database replication support is added in DooPHP.

Most simple frameworks/application have no separation of Reads and Writes of the DB. Once the projects outgrow a single server RDBMS the next step is often to do a Master/Slave setup in MySQL.

In a Master/Slave setup expensive and less frequent writes are channeled to the Master server while reads are channelled to the Slave server.

In DooPHP, we simplifies thing to merely just define the Slave server configurations in db.conf.php

You need to call Doo::useDbReplicate() in the bootstrap index.php, and that's all!

The query stuffs remain the same.

To setup:

//This will serve as the Master
$dbconfig['dev'] = array('localhost', 'db', 'root', '1234', 'mysql',true);

//slave with the same info as master
$dbconfig['slave'] = array('192.168.1.1', '192.168.1.2', '192.168.1.3');

//OR ...
//slave with different info, use a string if it's same as the master info.
$dbconfig['slave'] = 
	array(
	   array('192.168.1.1', 'db', 'dairy', '668dj0', 'mysql',true),
	   array('192.168.1.2', 'db', 'yuhus', 'gu34k2', 'mysql',true),
	   array('192.168.1.3', 'db', 'lily', '84ju2a', 'mysql',true),
	   '192.168.1.4'
    );

In index.php just add a line Doo::useDbReplicate() before setting up the DB.

Doo::useDbReplicate();
Doo::db()->setMap($dbmap);
Doo::db()->setDb($dbconfig, $config['APP_MODE']);

Published under: Tips & Tricks Share/Save/Bookmark

Using DooPHP on Nginx Rewrite Rule2009-08-12 03:10:36

Using DooPHP on Nginx Rewrite Rule

For those who are using DooPHP with Nginx and wanted to have clean URLs without the index.php, here's my settings for the rewrite rules. I hope it works for you.

      location ~ \.php {     
         fastcgi_pass  127.0.0.1:9000;
         fastcgi_index index.php;
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME C:/nginx/html/$fastcgi_script_name;
         fastcgi_param PATH_INFO $fastcgi_script_name;
         access_log off;
      }
      
      location /doophp_svn/app/ {
         index  index.php;
         if (!-e $request_filename){
            rewrite (.*) /doophp_svn/app/index.php/$1;
         }
      }

It can be access via:

http://localhost/doophp_svn/app/
http://localhost/doophp_svn/app/index.php
http://localhost/doophp_svn/app/allurl
http://localhost/doophp_svn/app/index.php/allurl

Also, remember to change the configs in the demos for them to work properly. Do change the SITE_PATH, BASE_PATH, SUBFOLDER and APP_URL.

If you have a better solution, do post it in the Tips & Tricks forum


Published under: Tips & Tricks Share/Save/Bookmark

Tips on Configuration2009-07-23 11:20:27

Tips on Configuration

As you can see from the demos, DooPHP does not use any Globals or had any define() used in the code. All configs are done in common.conf.php where variables are defined in assoc array style.

Other than the default configurations which are all in Capitalized characters, you can define your own setting variables. It is recommended that you define them in lowercase as DooPHP might add on new configs in later versions.

$config['salt_key'] = 'jjr7&688e-h3er';
$config['blog_pagesize'] = 12;

#retrieve in your code via:
Doo::conf()->salt_key;
Doo::conf()->blog_pagesize;

This is one good thing about DooPHP as it will not conflict with your application since no define() or globals are used. Not a single one ;)


Published under: Tips & Tricks Share/Save/Bookmark

About

Categories

Archives


Syndication