# Plugins Not Working

**URL:** <https://discourse.cakephp.org/t/plugins-not-working/5796>\
**Category:** Plugins\
**Created:** [March 15, 2019, 5:11pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796 "2019-03-15T17:11:33Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 5:11pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/1 "2019-03-15T17:11:33Z")

</div>

So I have created a custom plugin using 3.7, but i cannot get it to work.

bin/cake bake plugin Finance  
bin/cake bake all purchase\_orders --plugin Finance

**My composer.json :**

```
 "autoload": {
        "psr-4": {
            "App\\": "src/",
            "Finance\\": "./plugins/Finance/src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests/",
            "Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
            "Finance\\Test\\": "./plugins/Finance/tests/"
        }
    },

```

**I also ran this:**  
composer dumpautoload

**navigate to /finance/purchaseOrders/index and get this error:**  
2019-03-15 17:04:26 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Finance could not be found.

**My vendor/cakephp-plugins.php has this line:**  
‘Finance’ =\> $baseDir . ‘/plugins/Finance/’,

**I have also tried adding autoload to the Application.php file:**  
`$this->addPlugin('Finance', ['autoload' => true]);`

I have tried a number of different options but cannot seem to figure this out, and have little to no help with debug logs

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 5:39pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/2 "2019-03-15T17:39:15Z")

</div>

Welcome to the community.

Please show routes.php

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 5:43pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/3 "2019-03-15T17:43:02Z")

</div>

**I have tied adding this to config/routes.php:**  
$routes-\>scope(’/finance’, function ($routes) {  
$routes-\>loadPlugin(‘Finance’);  
});

**plugins/Finance/config/routes.php:**  
Router::plugin(  
‘Finance’,  
[‘path’ =\> ‘/finance’],  
function (RouteBuilder $routes) {  
$routes-\>fallbacks(DashedRoute::class);  
}  
);

Still no luck

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 5:54pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/4 "2019-03-15T17:54:41Z")

</div>

What does you " **purchaseOrders**" look like?

I just: baked the plugin.  
Created a controller file called **PurchaseorderController.php** in `APP/plugins/src/Controller`

```
<?php
namespace Finance\Controller;
use App\Controller\AppController;

class PurchaseorderController extends AppController
{
	public function index()
	{

	}
}

```

Navigated to /finance/purchaseorder/index

and it gave me missing template error.

Conclusion: It is working.

What did you do differently?

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:00pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/5 "2019-03-15T18:00:12Z")

</div>

Just did exact steps as you mentioned.

Try navigating to /finance/PurchaseOrders/index

It will work! Capital P

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:07pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/6 "2019-03-15T18:07:50Z")

</div>

**Ya, its not working. My PurchaseOrdersController.php:**

```
<?php
namespace Finance\Controller;

use Finance\Controller\AppController;
use Cake\ORM\TableRegistry;

class PurchaseOrdersController extends AppController
{
  
    public function index()
    {

```

…

Ya, its not working for me…

I wonder if it has anything to do with Centos 7. I have selinux off, but think there might be some permissions issue

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:30pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/7 "2019-03-15T18:30:47Z")

</div>

You are not seeing Server App’s error. What you are seeing is a cake error. Application level exception.  
However…  
I reckon, there is an issue with php start up. Can you confirm if PHP was able to load dynamic library http.so ?  
Also, if you are on a shared hosting using CentOS, it wont work!

`php -m | grep http`

If it shows http, then we can debug further, otherwise just change the host.

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:33pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/8 "2019-03-15T18:33:36Z")

</div>

No http …  
Also not on shared server…

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:34pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/9 "2019-03-15T18:34:24Z")

</div>

What PHP Version are you on?

Do you have root?

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:35pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/10 "2019-03-15T18:35:01Z")

</div>

php 7.1.26  
root = yes

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:35pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/11 "2019-03-15T18:35:51Z")

</div>

Run as root:

`php71enmod http`

restart web server.

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:37pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/12 "2019-03-15T18:37:36Z")

</div>

php71enmod http  
-bash: php71enmod: command not found

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:40pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/13 "2019-03-15T18:40:38Z")

</div>

Jeez!

php (hit tab twice), what is the list you see? as root.

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:41pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/14 "2019-03-15T18:41:14Z")

</div>

php php-cgi php-config phpize

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:44pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/15 "2019-03-15T18:44:09Z")

</div>

What the … phpenmod

Try:

`phpenmod http`

If it says phpenmod command not found.

Head over to php.ini file (loaded by your web server) and uncomment the line which ends with http.so (uncomment = remove semi-colon)

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:49pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/16 "2019-03-15T18:49:04Z")

</div>

No: phpenmod http  
No: http.so in /etc/php.ini

---

<div class="post-metadata">

**Author:** ![karmicdice](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/karmicdice/32/1298_2.png) [@karmicdice](https://discourse.cakephp.org/u/karmicdice)\
**Post date:** [March 15, 2019, 6:54pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/17 "2019-03-15T18:54:50Z")

</div>

Right!

Test the same code in ubuntu, if it is possible, move to a different OS. Cent is notorious to even run Laravel properly at times.

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [March 15, 2019, 6:55pm UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/18 "2019-03-15T18:55:43Z")

</div>

Sold… I am moving this weekend. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![FinlayDaG33k](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/finlaydag33k/32/1049_2.png) [@FinlayDaG33k](https://discourse.cakephp.org/u/FinlayDaG33k)\
**Post date:** [March 18, 2019, 6:48am UTC](https://discourse.cakephp.org/t/plugins-not-working/5796/19 "2019-03-18T06:48:29Z")

</div>

May I recommend to look into Docker?  
This way, you can make the “works on my machine” scenarios less common 😛
