wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

add 'CakeResque.Status.lib' config option #42

Closed joshuapaling closed 10 years ago

joshuapaling commented 10 years ago

It's already done correctly for the 'php-resque-ex' and 'php-resque-ex-scheduler' packages. I've just added the ability to specify a path to the 'resque-status' package via the configs, so it's consistent with the other two.

The reason I need it is because I'm using Composer to install the Cake-Resque plugin itself - not just its dependencies. So, Composer installs ALL dependent packages in /Vendors - not in the CakePlugin::path('CakeResque') . 'vendor' . DS; directory. So, I need to be able to specify the correct path to that via a config option.

You'll see in my comments that I've done a work around so as not to break things for existing users, but really I think this config option should probably be required in the next major version.

Also, on another note, I think the $pluginVendorPath itself should probably be configurable for the same reason - people using composer may have different vendor paths. However, I I haven't changed that in this PR.

FYI, my own custom bootstrap file looks like this:

$vendorPaths = App::path('Vendor');
$appVendorPath = $vendorPaths[0];
Configure::write('CakeResque.Resque.lib', $appVendorPath . 'kamisama' . DS . 'php-resque-ex');
Configure::write('CakeResque.Scheduler.lib', $appVendorPath . 'kamisama' . DS . 'php-resque-ex-scheduler');
Configure::write('CakeResque.Status.lib', $appVendorPath . 'kamisama' . DS . 'resque-status' );

Since I'm having composer install them with the exact same name but just at a different location, if there was a config option for the $pluginVendorPath then all I'd need to do is this:

$vendorPaths = App::path('Vendor');
$appVendorPath = $vendorPaths[0];
Configure::write('CakeResque.PluginVendorPath', $appVendorPath);

(of course, anyone using Composer to install their Cake plugins is in the same situation)

Signed-off-by: Joshua Paling joshua.paling@gmail.com

wa0x6e commented 10 years ago

So you're installing the plugin with a composer file located in the app folder ? And CakeResque is a dependency in that composer file ?

joshuapaling commented 10 years ago

Pretty much... the composer file is actually just above my app directory. (I downloaded the default cake zip file, and just went with that - so my top level folder has /app, /Config, /lib, index.php and more - including my composer.json.)

I've pasted my composer.json below. Since I've specified that app/Vendor/ is my vendor-dir, it installs all of Cake-Resque's dependencies in there. Make sense?

{
    "name": "the-big-vault",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/joshuapaling/cakephp-upload.git"
        }
    ],
    "require": {
        "josegonzalez/cakephp-upload": "dev-feature-honour-exif-data as 1.0.0",
        "cakedc/migrations": "2.2.2",
        "cakedc/search": "1.1.1",
        "cakephp/debug_kit": "2.2.1",
        "kamisama/cake-resque": "4.0.2"
    },
    "config": {
        "vendor-dir": "app/Vendor/"
    },
    "extra": {
       "installer-paths": {
         "app/Plugin/Upload": ["josegonzalez/cakephp-upload"],
         "app/Plugin/Migrations": ["cakedc/migrations"],
         "app/Plugin/Search": ["cakedc/search"],
         "app/Plugin/DebugKit": ["cakephp/debug_kit"],
         "app/Plugin/CakeResque": ["kamisama/cake-resque"]
       }
     }

}
wa0x6e commented 10 years ago

What's your local machine config ?

wa0x6e commented 10 years ago

The tests are failing on Cake 2.2, since Configure::check() was not implemented yet

joshuapaling commented 10 years ago

OK I'll fix that now, sorry

joshuapaling commented 10 years ago

OK done - I just changed 'check' to 'read'. Should work the same.

joshuapaling commented 10 years ago

Done.

joshuapaling commented 10 years ago

done.

wa0x6e commented 10 years ago

Thanks