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
Welcome to the community.
Please show routes.php
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
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?
Just did exact steps as you mentioned.
Try navigating to /finance/PurchaseOrders/index
It will work! Capital P
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
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.
No http …
Also not on shared server…
What PHP Version are you on?
Do you have root?
php71enmod http
-bash: php71enmod: command not found
Jeez!
php (hit tab twice), what is the list you see? as root.
php php-cgi php-config phpize
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)
No: phpenmod http
No: http.so in /etc/php.ini
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.
Sold… I am moving this weekend. Thanks for the help.
May I recommend to look into Docker?
This way, you can make the “works on my machine” scenarios less common