0

CakePHP is great for developing web facing and backend server applications using Controller and shells but I have a case where I just need to embed the library inside an app. I'm using TideSDK and I need to expose some PHP functionality to it and I would like to build it in a manner similar to how cakePHP models behave but I don't need all the other fluff that cake provides like Shells, Controllers, Helpers etc. Just the code ORM / Model / ActiveRecord stuff that makes working with data so easy.

Is there a way to use cakePHP scaled down and invoked simply through a PHP class (no web servers, shells, etc..)

Or are there frameworks similar to CakePHP that are ment for this specific domain?

I'm asking because I started doing it myself but I keep re-inventing pieces of CakePHP core which is obviously not ideal.

carcus88
  • 137
  • 1
  • 7

2 Answers2

2

Since 2.x all code is lazy loaded, so if you do not use $this->SomeHelper->method() it wont be loaded. App::uses() registers the class in the autoloader.

The entire method.

/**
 * Declares a package for a class. This package location will be used
 * by the automatic class loader if the class is tried to be used
 *
 * ....
 *
 * @param string $className the name of the class to configure package for
 * @param string $location the package name
 * @return void
 * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses
 */
    public static function uses($className, $location) {
        self::$_classMap[$className] = $location;
    }

If you dont want to use something, just dont call it.

You can look at the index.php for how cake is initialised. Dispatcher is the clue, that gets things going.

dogmatic69
  • 7,574
  • 4
  • 31
  • 49
1

If you’re just wanting model functionality, then it sounds like what you’re looking for is an ORM (object relational mapper).

Some of the common ones are:

I think it’s also possible to use FuelPHP’s ORM package standalone, but I may be wrong on this.

Martin Bean
  • 38,379
  • 25
  • 128
  • 201