Software and Technology Ramblings

January 11, 2010

Calling CakePHP Code from Other PHP Code

Filed under: CakePHP — Tags: , — Doug Hays @ 11:13 pm

In order to call CakePHP from non-CakePHP code, we will copy index.php from /app/webroot and put it into our non-CakePHP codebase as cakephp.php.

Then, we’ll create a function requestCakePHP that requires the cakephp.php file:

function requestCakePHP($url)

{

// Set the url parameter for cakephp
$_GET['url'] = $url;

require_once 'cakephp.php';

// Fire up CakePHP and buffer results
ob_start();
$Dispatcher= new Dispatcher ();
$Dispatcher->dispatch($url);

return ob_get_clean();

}
?>

Then, whenever we need to call for some Cake, we just call requestCake with the URL minus the hostname:


echo requestCakePHP("/webpages/view/2");

In the example above, I have a webpages controller, a view action and am viewing webpage #2.

March 17, 2009

Installing CakePHP 1.2 in a Subdirectory

Filed under: CakePHP — Doug Hays @ 4:02 pm

I needed to test some CakePHP code on a client’s 1and1 server today, so I dropped my CakePHP app in a subdirectory (called agents2) on his site.  But, after doing so, I kept getting “Class ‘Configure’ not found”.  Luckily, I stumbled upon this blog post over at kushaura.com which saved me.

The core issue was with my root .htaccess file which needed to be changed to:

      RewriteEngine on
      RewriteBase    /agents2/

      RewriteRule    ^$ app/webroot/    [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule (.*) app/webroot/$1 [L]

And that did the trick.

Thanks, Kushaura.com!

April 29, 2008

Announcing Dingus CMS

Filed under: CMS, CakePHP, MySQL — Doug Hays @ 11:20 am

We have written a very basic CMS system (just like everyone else has) that we use on a handful of our clients’ websites. We wanted a CMS system that was:

  • Easy to deploy
  • Simple to re-skin when provided an HTML/CSS design
  • Search Engine Friendly
  • Easy enough that non-technical people could administer the content of the site
  • Lightweight enough so that the system could be the foundation of a larger application or website
  • Built using CakePHP and MySQL

After looking around the web for 5 minutes, and not finding anything, we decided to build it ourselves. So, here it is, Dingus CMS.

In order to install and use Dingus CMS:

  1. You’ll need a basic PHP/MySQL/Apache environment. (Note: PHP 5 is recommended and Apache needs mod_rewrite)
  2. Download the source.
  3. Extract the source into the document root of your website. Note that the app, cake, docs, etc… directories should be at the root of your site
  4. Configure the database connection in app/config/database.php
  5. Run the SQL in sql/dingus_cms_db_setup.sql
  6. Go to http://localhost and you should be up and running!

Note that Dingus CMS comes with built-in search and site map pages available at http://localhost/search.html and http://localhost/site-map.html

Finally, you may be wondering what a Dingus is. You’ll have to stay tuned for a full explanation.

Powered by WordPress