srs81 / CakePHP-AjaxMultiUpload

CakePHP 2 plugin to allow for easy multi-file upload with AJAX
Other
65 stars 32 forks source link

A few suggestions to improve cake integration #29

Closed destinydriven closed 11 years ago

destinydriven commented 11 years ago
  1. Using App:import() in place of require_once to load external library in Vendor folder
  2. Allowing CakePlugin bootstrap option to load the plugin's bootstrap file to avoid duplicate code through the repeated usage of require_once(). Removed instances where bootstrap was loaded.
  3. Allowing the component to load the helper automatically since both are needed anyway. No need to explicitly load helper once the component is added to controllers.
  4. Added visibility keywords.
  5. Updated README.md. Added instruction to use CakePlugin::load('AjaxMultiUpload', array('bootstrap' => true)); so bootstrap is loaded automatically.
gabeidx commented 11 years ago

A Quote from @lorenzo, one of the developers behind CakePHP:

Now, using App::import() for vendors is kind of silly, if you think about it. It is just an expensive, verbose and very > silly wrapper for require_once().

In 2.0, we actually encourage people to use require or require_once for their Vendor libraries. You can get the location of the Vendor folder using App::path('Vendor') or just APP . 'Vendor' . DS.

So, using App::import() isn't really an improvement.

destinydriven commented 11 years ago

gabrielizaias, thank you for that heads up. I was always aware that App:import() was just an expensive wrapper for require() but I had not seen any instruction to replace it in Cake. I will change the pull request to reflect this and resubmit.