Missing Controller Exception after installing FriendsOfCake/cakephp-csvview - php

I installed FriendsOfCake/cakephp-csvview using
php ../composer.phar require friendsofcake/cakephp-csvview:~3.0.
After which all pages show Missing Controller Exception (they were definitely OK), even after commenting out Plugin::load('CsvView') in bootstrap.php. I doubt php was unable to locate the controller class but don't know why. I have used find . -mtime -1, no files under src have changed.
Could anyone please tell me how Cakephp figures out the class file locations so I can troubleshoot?
Stack trace below:
2016-10-04 03:20:39 Warning: Headers already sent in {base}/vendor/cakephp/cakephp/src/Error/Debugger.php:753
2016-10-04 03:20:39 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Holders could not be found.
Exception Attributes: array (
'class' => 'Holders',
'plugin' => false,
'prefix' => false,
'_ext' => false,
)
Request URL: /
Client IP: 127.0.0.1
Stack Trace:
#0 {base}/vendor/cakephp/cakephp/src/Http/ControllerFactory.php(72): Cake\Http\ControllerFactory->missingController(Object(Cake\Network\Request))
#1 {base}/vendor/cakephp/cakephp/src/Routing/Filter/ControllerFactoryFilter.php(63): Cake\Http\ControllerFactory->create(Object(Cake\Network\Request), Object(Cake\Network\Response))
#2 {base}/vendor/cakephp/cakephp/src/Routing/Filter/ControllerFactoryFilter.php(49): Cake\Routing\Filter\ControllerFactoryFilter->_getController(Object(Cake\Network\Request), Object(Cake\Network\Response))
#3 {base}/vendor/cakephp/cakephp/src/Routing/DispatcherFilter.php(144): Cake\Routing\Filter\ControllerFactoryFilter->beforeDispatch(Object(Cake\Event\Event))
#4 {base}/vendor/cakephp/cakephp/src/Event/EventManager.php(426): Cake\Routing\DispatcherFilter->handle(Object(Cake\Event\Event), Object(Cake\Network\Request), Object(Cake\Network\Response))
#5 {base}/vendor/cakephp/cakephp/src/Event/EventManager.php(391): Cake\Event\EventManager->_callListener(Array, Object(Cake\Event\Event))
#6 {base}/vendor/cakephp/cakephp/src/Event/EventDispatcherTrait.php(78): Cake\Event\EventManager->dispatch(Object(Cake\Event\Event))
#7 {base}/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(81): Cake\Http\ActionDispatcher->dispatchEvent('Dispatcher.befo...', Array)
#8 {base}/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(60): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#9 {base}/webroot/index.php(37): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#10 {main}

If at all, CakePHP only tries to figure fully qualified classnames from shorter ones, it doesn't handle including class files or figuring their locations, as of CakePHP 3 it relies on the composer autoloader (vendor/autoload.php) to do that.
If things broke after updating a dependency, which will also cause the autoloader to be re-dumped, chances are good that the autoloader broke (for whatever reason).

Related

What causes Symfony to call a service?

I have an issue and instead of asking just how to solve it, I would to better understand what is happening so that I could solve it myself.
Using api-platform 2.6.6, I successfully added an endpoint to SwaggerUI to retrieve a JWT Token. I later upgraded to api-platform 2.7.x-dev and the endpoint is no longer is displayed. While my end goal is to restore the endpoint, my immediate goal is to better understand how Symfony is configured to that it will call a service.
According to the 2.6.6 api-platform documentation to add the endpoint a decorator is added and it is registered as a service.
api/src/OpenApi/JwtDecorator.php
<?php
declare(strict_types=1);
namespace App\OpenApi;
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\OpenApi\Model;
final class JwtDecorator implements OpenApiFactoryInterface
{
public function __construct(
private OpenApiFactoryInterface $decorated
) {}
public function __invoke(array $context = []): OpenApi
{
// script goes here.
}
}
api/config/services.yaml
services:
# ...
App\OpenApi\JwtDecorator:
decorates: 'api_platform.openapi.factory'
arguments: ['#.inner']
To ensure that this single service is solely responsible for adding the endpoint, I intentionally did not make any changes to api/config/packages/security.yaml, api/config/routes.yaml, and api/config/packages/api_platform.yaml to ensure they were not causing the endpoint from being displayed on the original 2.6.6 version and they were not. I also looked at what changes were made when using composer to install jwt-auth, and nothing seems relevant. I also found that I could rename JwtDecorator to SomeOtherName and have ruled out that the class name has special meaning.
Next, I placed a debug_print_backtrace() in the App\OpenApi\JwtDecorator file outside of the class, and found that when using either 2.6.6 or 2.7.x-dev, the command is executed and the backtrace is identical. My hypothesis is that upon any request, symfony will first execute include() on every file with a php extension located in src (unless maybe explicitly instructed not to in some config file), check if cache is fresh (and if not create cache files), and use the results to populate the service container. Please confirm whether this is correct.
Backtrace in api/src/OpenApi/JwtDecorator.php file (not in constructor)
#0 include() called at [/srv/api/vendor/symfony/error-handler/DebugClassLoader.php:349] # line 349 for 2.6.6 and 346 for 2.7.x-dev.
#1 Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#2 ReflectionClass->__construct() called at [/srv/api/vendor/symfony/config/Resource/ReflectionClassResource.php:107]
#3 Symfony\Component\Config\Resource\ReflectionClassResource->computeHash() called at [/srv/api/vendor/symfony/config/Resource/ReflectionClassResource.php:54]
#4 Symfony\Component\Config\Resource\ReflectionClassResource->isFresh() called at [/srv/api/vendor/symfony/config/Resource/SelfCheckingResourceChecker.php:34]
#5 Symfony\Component\Config\Resource\SelfCheckingResourceChecker->isFresh() called at [/srv/api/vendor/symfony/config/ResourceCheckerConfigCache.php:99]
#6 Symfony\Component\Config\ResourceCheckerConfigCache->isFresh() called at [/srv/api/vendor/symfony/config/ConfigCache.php:60]
#7 Symfony\Component\Config\ConfigCache->isFresh() called at [/srv/api/vendor/symfony/http-kernel/Kernel.php:451]
#8 Symfony\Component\HttpKernel\Kernel->initializeContainer() called at [/srv/api/vendor/symfony/http-kernel/Kernel.php:786]
#9 Symfony\Component\HttpKernel\Kernel->preBoot() called at [/srv/api/vendor/symfony/http-kernel/Kernel.php:187]
#10 Symfony\Component\HttpKernel\Kernel->handle() called at [/srv/api/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:37]
#11 Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() called at [/srv/api/vendor/autoload_runtime.php:35]
#12 require_once(/srv/api/vendor/autoload_runtime.php) called at [/srv/api/public/index.php:5]
Next, I did the same but this time within JwtDecorator's constructor, and it was executed only 2.6.6 but not 2.7.x-dev. Now I know the endpoint is not being displayed because the decorator isn't being called.
I then start looking at the classes in ContainerIx5JWFD, and I find the name of the class is always "get" + servicesClassName + "service". Now I see why I was able to change the name of the service from JwtDecorator to SomeOtherName and it still worked. I also find that the ContainerIx5JWFD\getJwtDecoratorService class only exists for 2.6.6 and not for 2.7.x-dev.
2.6.6 backtrace JwtDecorator::__construct()
#0 App\OpenApi\JwtDecorator->__construct() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/getJwtDecoratorService.php:25]
#1 ContainerIx5JWFD\getJwtDecoratorService::do() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/App_KernelDevDebugContainer.php:644]
#2 ContainerIx5JWFD\App_KernelDevDebugContainer->load() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/getApiPlatform_SwaggerUi_ActionService.php:23]
#3 ContainerIx5JWFD\getApiPlatform_SwaggerUi_ActionService::do() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/App_KernelDevDebugContainer.php:644]
#4 ContainerIx5JWFD\App_KernelDevDebugContainer->load() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/getApiPlatform_Swagger_Action_UiService.php:22]
#5 ContainerIx5JWFD\getApiPlatform_Swagger_Action_UiService::do() called at [/srv/api/var/cache/dev/ContainerIx5JWFD/App_KernelDevDebugContainer.php:644]
#6 ContainerIx5JWFD\App_KernelDevDebugContainer->load() called at [/srv/api/vendor/symfony/dependency-injection/Container.php:237]
#7 Symfony\Component\DependencyInjection\Container->make() called at [/srv/api/vendor/symfony/dependency-injection/Container.php:219]
#8 Symfony\Component\DependencyInjection\Container->get() called at [/srv/api/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:53]
#9 Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->instantiateController() called at [/srv/api/vendor/symfony/framework-bundle/Controller/ControllerResolver.php:29]
#10 Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->instantiateController() called at [/srv/api/vendor/symfony/http-kernel/Controller/ControllerResolver.php:108]
#11 Symfony\Component\HttpKernel\Controller\ControllerResolver->createController() called at [/srv/api/vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:42]
#12 Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->createController() called at [/srv/api/vendor/symfony/http-kernel/Controller/ControllerResolver.php:86]
#13 Symfony\Component\HttpKernel\Controller\ControllerResolver->getController() called at [/srv/api/vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php:38]
#14 Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController() called at [/srv/api/vendor/symfony/http-kernel/HttpKernel.php:139]
#15 Symfony\Component\HttpKernel\HttpKernel->handleRaw() called at [/srv/api/vendor/symfony/http-kernel/HttpKernel.php:78]
#16 Symfony\Component\HttpKernel\HttpKernel->handle() called at [/srv/api/vendor/symfony/http-kernel/Kernel.php:199]
#17 Symfony\Component\HttpKernel\Kernel->handle() called at [/srv/api/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:37]
#18 Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() called at [/srv/api/vendor/autoload_runtime.php:35]
#19 require_once(/srv/api/vendor/autoload_runtime.php) called at [/srv/api/public/index.php:5]
So, to troubleshoot this, I shouldn't be following this code path but really the code which creates these cached files. I am stuck and begging for help. What triggers Symfony to create these classes so that the service is called? How do I determine what is different between the 2.6.6 and 2.7.x-dev so it is only called on 2.6.6?
The most important information: wait for the official release of that library, as it will contain a list of upgrades. Renaming a service (like happened here) will probably be listed there.
To get to the point: by searching for api_platform.openapi.factory in the source code, I've found that the service was renamed in a pull request. The new service name is api_platform.openapi.factory.next

Mediawiki: own Extension Specialpage - missing alias

I just tried to make my own wiki-extension following these tut: Mediawiki - Develop Extensions
The Extensions has a SpecialPage and when i visist the mediawiki - SpecialPages Site i get the following error:
[cb6b6dfb1a33d10f07bcbc44] /index.php/Spezial:Spezialseiten Wikimedia\Assert\ParameterAssertionException from line 63 of D:\Wiki\mediawiki\wiki\vendor\wikimedia\assert\src\Assert.php: Bad value for parameter $dbkey: should not be empty
Backtrace:
#0 D:\Wiki\mediawiki\wiki\includes\title\TitleValue.php(82):Wikimedia\Assert\Assert::parameter(boolean, string, string)
#1 D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPage.php(100): TitleValue->__construct(integer, string, string)
#2 D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPage.php(84): SpecialPage::getTitleValueFor(string, boolean, string)
#3 D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPage.php(629): SpecialPage::getTitleFor(string, boolean)
#4 D:\Wiki\mediawiki\wiki\includes\specials\SpecialSpecialpages.php(70): SpecialPage->getPageTitle()
#5 D:\Wiki\mediawiki\wiki\includes\specials\SpecialSpecialpages.php(42): SpecialSpecialpages->getPageGroups()
#6 D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPage.php(522): SpecialSpecialpages->execute(NULL)
#7 D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPageFactory.php(576): SpecialPage->run(NULL)
#8 D:\Wiki\mediawiki\wiki\includes\MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext)
#9 D:\Wiki\mediawiki\wiki\includes\MediaWiki.php(851): MediaWiki->performRequest()
#10 D:\Wiki\mediawiki\wiki\includes\MediaWiki.php(512): MediaWiki->main()
#11 D:\Wiki\mediawiki\wiki\index.php(43): MediaWiki->run()
#12 {main}
with the Debug-notice:
Notice: Did not find alias for special page ''. Perhaps no aliases are defined for it? [Called from SpecialPageFactory::getLocalNameFor in D:\Wiki\mediawiki\wiki\includes\specialpage\SpecialPageFactory.php at line 691] in D:\Wiki\mediawiki\wiki\includes\debug\MWDebug.php on line 311
So why does it search for an empty alias '' when trying to build my SpecialPage?
Could sth gone wrong with my MyExtensions.i18n.alias.php?
or Does any1 know if this kind of error has a deeper meening?
It sounds like an issue with the definition of your special page alias.
Make sure your alias for your SpecialPage is defined correctly, and that the alias page itself is properly attached in your extension in 'ExtensionMessagesFiles' (so it's being read).
See https://www.mediawiki.org/wiki/Manual:Special_pages#The_aliases_file for more information.
Also, you can use https://tools.wmflabs.org/mwstew/ tool to create an extension boilerplate with your special page name and alias generated for you.

PHP Cpanel_PublicAPI Create Account passing incorrect variables

I am sorry if this request is in the wrong area.
I am learning to use PHP and the CPanel API. I've got the following code and it's giving me a stack error because I am missing something seemingly simple
$domain = array('username' => 'bobbie', 'domain' => 'bobbie.com', 'pass' => 'bobbie123');
$acct = $cp->whm_api('createacct', $domain);
echo "WHM Create: {$acct->createacct}\n";
I know I'm connecting to WHM properly because my code before this outputs the version of WHM correctly. The above code is giving me an error stating that createacct needs to be passed an array as the first parameter:
WHM Version: 11.54.0.21
PHP Fatal error: Uncaught exception 'Exception' with message 'createacct requires that first parameter passed to it is an array' in /root/whmrm/Cpanel/Service/XmlapiClientClass.php:146
Stack trace:
#0 [internal function]: Cpanel_Service_XmlapiClientClass->createacct('bobbie', 'bobbie.com', 'bobbie123')
#1 /root/whmrm/Cpanel/Service/WHM.php(195): call_user_func_array(Array, Array)
#2 [internal function]: Cpanel_Service_WHM->__call('createacct', Array)
#3 [internal function]: Cpanel_Service_WHM->createacct('bobbie', 'bobbie.com', 'bobbie123')
#4 /root/whmrm/Cpanel/PublicAPI.php(525): call_user_func_array(Array, Array)
#5 /root/whmrm/create_sites_on_server.php(68): Cpanel_PublicAPI->__call('whm_api', Array)
#6 /root/whmrm/create_sites_on_server.php(68): Cpanel_PublicAPI->whm_api('createacct', Array)
#7 {main}
thrown in /root/whmrm/Cpanel/Service/XmlapiClientClass.php on line 146
Line 3 of the output is showing that I'm not sending the data properly. Any help would be appreciated. I've googled and most of the results give me information about the xml_api and how to use that. Thanks for your assistance.
Looking at the source for the PublicAPI class, it appears that if an array is given as the parameters, it only calls the resulting function passing the first element from the array (source).
I was able to create an account using this code:
$cp = Cpanel_PublicAPI::getInstance($config);
$whm = Cpanel_PublicAPI::factory('whm');
$domain = array(
'domain' => 'mydomain.com',
'username' => 'drewt2',
'password' => 'myp4ssw0rd!'
);
$response = $whm->createacct($domain);
You can see the functions and there parameters here: Cpanel_Service_XmlapiClientClass.
Unfortunately, the code hasn't been updated in 5 years, and the examples aren't that helpful so you'll likely have to look through the code to figure out most of what you'll want to do.

CakePHP v3.x how to bake without database connection

I'm using CakePHP v3.x and my app doesn't have any models but I'd like to back a couple views or controllers.
$ bin/cake bake template Reports
I tried:
* using the --connection option with false or an empty string
* Removing Datasources from app.php
* Leaving in Datasources but set Datasources['default'] to false
All of these result in an error:
Welcome to CakePHP v3.1.2 Console
---------------------------------------------------------------
App : src
Path: /Applications/MAMP/htdocs/listings/src/
PHP : 5.6.10
---------------------------------------------------------------
Exception: The datasource configuration "default" was not found. in [/Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php, line 187]
2015-10-22 02:30:48 Error: [Cake\Datasource\Exception\MissingDatasourceConfigException] The datasource configuration "default" was not found.
Exception Attributes: array (
'name' => 'default',
)
Stack Trace:
#0 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/ORM/Locator/TableLocator.php(164): Cake\Datasource\ConnectionManager::get('default')
#1 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/ORM/TableRegistry.php(109): Cake\ORM\Locator\TableLocator->get('Reports', Array)
#2 /Applications/MAMP/htdocs/listings/vendor/cakephp/bake/src/Shell/Task/TemplateTask.php(282): Cake\ORM\TableRegistry::get('Reports')
#3 /Applications/MAMP/htdocs/listings/vendor/cakephp/bake/src/Shell/Task/TemplateTask.php(147): Bake\Shell\Task\TemplateTask->_loadController()
#4 [internal function]: Bake\Shell\Task\TemplateTask->main('Reports')
#5 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/Shell.php(447): call_user_func_array(Array, Array)
#6 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/Shell.php(442): Cake\Console\Shell->runCommand(Array, false)
#7 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(212): Cake\Console\Shell->runCommand(Array, true, Array)
#8 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(179): Cake\Console\ShellDispatcher->_dispatch(Array)
#9 /Applications/MAMP/htdocs/listings/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(126): Cake\Console\ShellDispatcher->dispatch(Array)
#10 /Applications/MAMP/htdocs/listings/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#11 {main}
I doubt this will work any time soon. You can create feature request type ticket on Github but it's unlikely to happen, because bake uses the DB schema to read the fields and builds everything based on the schema.
Also the Table class, which replaced Model from Cake2, doesn't allow $useTable = false any more. Because a table requires a DB table. For model less forms see this link.

Yii framework - controller actions

I am trying to create sample project in yii but I am having this problem while trying to run my code:
CHttpException
The system is unable to find the requested action "error". (C:\wamp\www\yii\framework\web\CController.php:484)
#0 C:\wamp\www\yii\framework\web\CController.php(271): CController->missingAction('error')
#1 C:\wamp\www\yii\framework\web\CWebApplication.php(276): CController->run('error')
#2 C:\wamp\www\yii\framework\base\CErrorHandler.php(310): CWebApplication->runController('site/error')
#3 C:\wamp\www\yii\framework\base\CErrorHandler.php(183): CErrorHandler->render('error', Array)
#4 C:\wamp\www\yii\framework\base\CErrorHandler.php(108): CErrorHandler->handleException(Object(CHttpException))
#5 C:\wamp\www\yii\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent))
#6 [internal function]: CApplication->handleException(Object(CHttpException))
#7 {main}
Can anyone tell me the reason ? As I think this is not the problem of my code.
An exception has occurred (most likely due to a bug or misconfiguration) and Yii attempted to run the error handler, which in this case is the error action on the site controller.
The error occurs because you do not have a site controller, or it does not have an error action.

Categories