{"id":14788,"date":"2011-04-23T15:09:27","date_gmt":"2011-04-23T13:09:27","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=14788"},"modified":"2011-04-23T15:09:27","modified_gmt":"2011-04-23T13:09:27","slug":"disable-and-enable-cakephp-plugins-on-the-fly","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2011\/04\/23\/disable-and-enable-cakephp-plugins-on-the-fly\/","title":{"rendered":"Disable and enable CakePHP plugins on the fly"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I am currently working on a rather large project which is based on CakePHP framework. \u00a0In order to simplify the task, I&#8217;ve broken down the whole application into a number of CakePHP plugins. \u00a0Now, however, I want to enable\/disable plugins on the fly. \u00a0After a brief search around I couldn&#8217;t find how to do that. \u00a0Asking a question at #cakephp IRC channel did it. \u00a0RabidFire instantly replied with\u00a0<a href=\"http:\/\/groups.google.com\/group\/cake-php\/browse_thread\/thread\/9370aac4a0d80488?fwc=1&amp;pli=1\">the link that gave me an idea<\/a>. \u00a0 30 seconds later I had a working solution.<\/p>\n<p>CakePHP plugins extend AppController. \u00a0So all that one needs to do is add the following lines to <em>app\/app_controller.php<\/em> (Using CakePHP 2.0, but it&#8217;s trivial to adopt for earlier versions):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\ufeffpublic function beforeFilter() {\r\n    $allowedPlugins = array('crm', 'articles');\r\n    if (!empty($this-&gt;request-&gt;params&#x5B;'plugin']) &amp;&amp; !in_array($this-&gt;request-&gt;params&#x5B;'plugin'], $allowedPlugins)) {\r\n        throw new ForbiddenException();\r\n    }\r\n}\r\n<\/pre>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I am currently working on a rather large project which is based on CakePHP framework. \u00a0In order to simplify the task, I&#8217;ve broken down the whole application into a number of CakePHP plugins. \u00a0Now, however, I want to enable\/disable plugins on the fly. \u00a0After a brief search around I couldn&#8217;t find how to do that. &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2011\/04\/23\/disable-and-enable-cakephp-plugins-on-the-fly\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Disable and enable CakePHP plugins on the fly<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[1537],"keyring_services":[],"class_list":["post-14788","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-cakephp"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":27421,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/17\/cakephp-3-remove-shell-welcome-header\/","url_meta":{"origin":14788,"position":0},"title":"CakePHP 3 : Remove Shell Welcome Header","author":"Leonid Mamchenkov","date":"March 17, 2017","format":false,"excerpt":"CakePHP 3\u00a0has an excellent support for command line Shells, Tasks, and Console Tools. \u00a0There are a few that are bundled with the framework itself, and that come from a variety of plugins. \u00a0And, of course, you can have your own commands, specific to your application. [code light=\"true\"] $ .\/bin\/cake Welcome\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27363,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/26\/composer-require-inline-alias\/","url_meta":{"origin":14788,"position":1},"title":"Composer require inline alias","author":"Leonid Mamchenkov","date":"February 26, 2017","format":false,"excerpt":"Here's a feature of composer that I didn't know about until a few days ago - require inline alias. \u00a0Here's the example from the documentation: [code] { \"repositories\": [ { \"type\": \"vcs\", \"url\": \"https:\/\/github.com\/you\/monolog\" } ], \"require\": { \"symfony\/monolog-bundle\": \"2.0\", \"monolog\/monolog\": \"dev-bugfix as 1.0.x-dev\" } } [\/code] This is super\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22103,"url":"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/01\/cakephp-3-here-we-go-again\/","url_meta":{"origin":14788,"position":2},"title":"CakePHP 3, here we go again.","author":"Leonid Mamchenkov","date":"July 1, 2014","format":false,"excerpt":"As some of you might know, I'm a big fan of CakePHP framework. \u00a0I've used it on numerous projects since the beginning of times. \u00a0I've built projects small and large, migrated existing native PHP codebases to CakePHP and even survived a few major CakePHP upgrades - 1.2 to 2.0 comes\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26051,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/21\/adventure-in-composer-private-repositories\/","url_meta":{"origin":14788,"position":3},"title":"Adventure in composer private repositories","author":"Leonid Mamchenkov","date":"April 21, 2016","format":false,"excerpt":"First of all, I would like to take this opportunity and wish composer a happy birthday and many more years to come. \u00a0It's been five years, and the world of PHP has changed so drastically that not many people remember how it used to be before. I would have completely\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28879,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/10\/23\/go-monorepo\/","url_meta":{"origin":14788,"position":4},"title":"Go Monorepo","author":"Leonid Mamchenkov","date":"October 23, 2018","format":false,"excerpt":"As a maintainer and contributor to multiple, and often related, git repositories, I often find myself thinking that there must be a simpler way. Consider, for example, a variety of CakePHP plugins that we develop and maintain at work.\u00a0 Sure, each one provides a completely separate bit of functionality and\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28478,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/04\/17\/cakephp-3-6-0-release\/","url_meta":{"origin":14788,"position":5},"title":"CakePHP 3.6.0 release","author":"Leonid Mamchenkov","date":"April 17, 2018","format":false,"excerpt":"My all time favorite PHP framework - CakePHP has recently announced the availability of the long awaited version 3.6.0.\u00a0 What's so special about this particular version? - those of you not very familiar with CakePHP might ask.\u00a0 And I'll tell you. CakePHP is a well established framework, with long history\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/14788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=14788"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/14788\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=14788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=14788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=14788"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=14788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}