I find that when I try doing
$this->addElement('hidden', 'id');
And run, I get something like
Fatal error: Call to a member function getOrder() on a non-object in D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php on line 3318
Call Stack:
0.0002 329712 1. {main}() D:\Projects\Tickle\public\index.php:0
0.0726 1393760 2. Zend_Application->run() D:\Projects\Tickle\public\index.php:26
0.0726 1393760 3. Zend_Application_Bootstrap_Bootstrap->run() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Application.php:366
0.0727 1393816 4. Zend_Controller_Front->dispatch() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Application\Bootstrap\Bootstrap.php:97
0.1787 2026520 5. Zend_Controller_Dispatcher_Standard->dispatch() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Front.php:954
0.1860 2144464 6. Zend_Controller_Action->dispatch() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:295
0.2089 2771352 7. Zend_Controller_Action_HelperBroker->notifyPostDispatch() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Action.php:523
0.2090 2772208 8. Zend_Controller_Action_Helper_ViewRenderer->postDispatch() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Action\HelperBroker.php:277
0.2091 2772208 9. Zend_Controller_Action_Helper_ViewRenderer->render() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Action\Helper\ViewRenderer.php:957
0.2099 2772400 10. Zend_Controller_Action_Helper_ViewRenderer->renderScript() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Action\Helper\ViewRenderer.php:918
0.2099 2772400 11. Zend_View_Abstract->render() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Action\Helper\ViewRenderer.php:897
0.2100 2813576 12. Zend_View->_run() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\View\Abstract.php:880
0.2103 2814016 13. include('D:\Projects\Tickle\application\views\scripts\projects\edit.phtml') D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\View.php:108
0.2103 2814016 14. Zend_Form->__toString() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php:0
0.2103 2814016 15. Zend_Form->render() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php:2916
0.2117 2825200 16. Zend_Form_Decorator_FormElements->render() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php:2900
0.2120 2827128 17. Zend_Form->rewind() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php:0
0.2120 2827128 18. Zend_Form->_sort() D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Form.php:3225
When I try doing
$this->addElement('hidden', 'id2');
it works
My Zend_Form http://pastie.org/1425012 for reference
Finally direcovered =)
Change your property name $id to $_id (and also the references $this->_id). Zend form make use of the property name when you define the element. So, always use an underline or something else to diferenciate the names.
protected $_minimalMode;
protected $_id;
Related
I keep getting this error Slim Application Error after installing the new Slim 4 framework.
I tried switching back to old version of slim but I keep getting the same thing.
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
/**
* Instantiate App
*
* In order for the factory to work you need to ensure you have installed
* a supported PSR-7 implementation of your choice e.g.: Slim PSR-7 and a supported
* ServerRequest creator (included with Slim PSR-7)
*/
$app = AppFactory::create();
// Add Routing Middleware
$app->addRoutingMiddleware();
/*
* Add Error Handling Middleware
*
* #param bool $displayErrorDetails -> Should be set to false in production
* #param bool $logErrors -> Parameter is passed to the default ErrorHandler
* #param bool $logErrorDetails -> Display error details in error log
* which can be replaced by a callable of your choice.
* Note: This middleware should be added last. It will not handle any exceptions/errors
* for middleware added after it.
*/
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
// Define app routes
$app->get('/hello/{name}', function (Request $request, Response $response, $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
// Run app
$app->run();
Output:
Slim Application Error
The application could not run because of the following error:
Details
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Line: 91
Trace:
#0 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(57): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request))
#1 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner))
#2 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(89): class#anonymous->handle(Object(Slim\Psr7\Request))
#3 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class#anonymous))
#4 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): class#anonymous->handle(Object(Slim\Psr7\Request))
#5 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/App.php(206): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request))
#6 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/App.php(190): Slim\App->handle(Object(Slim\Psr7\Request))
#7 /opt/lampp/htdocs/MyocappAPI/public/index.php(41): Slim\App->run()
#8 {main}
I'm glad OP figured it out, but he didn't share his solution so here is what worked for me:
$app = AppFactory::create();
$app->setBasePath("/slimapp/public/index.php");
where the full path to my starter page is:
C:\xampp\htdocs\slimapp\public\index.php
To test my starter page, the URL I used was:
localhost/slimapp/public/index.php/hello/Beautiful
I think in Slim 3 you didn't need to manually set the base path, but you do in Slim 4. I don't know if it's a bug but this worked.
Slim 4 has some bugs in routing. So,Downgrade the slim version to 3.*
Reference:
https://discourse.slimframework.com/t/slim-4-httpnotfoundexception/3273/18
I'm trying to upgrade my nestjs from 5.0.beta to 5.1.
At boottime I'm getting the following error. Not sure where to look for a solution. Thanks for any help.
TypeError: Cannot read property 'name' of undefined
at Module.addModuleAsComponent (myApp/node_modules/#nestjs/core/injector/module.js:72:45)
at Module.addCoreInjectables (myApp/node_modules/#nestjs/core/injector/module.js:56:14)
at new Module (myApp/node_modules/#nestjs/core/injector/module.js:24:14)
at NestContainer.addModule (myApp/node_modules/#nestjs/core/injector/container.js:35:24)
at DependenciesScanner.storeModule (myApp/node_modules/#nestjs/core/scanner.js:32:30)
at DependenciesScanner.scanForModules (myApp/node_modules/#nestjs/core/scanner.js:22:20)
at DependenciesScanner.scan (myApp/node_modules/#nestjs/core/scanner.js:17:20)
at exceptions_zone_1.ExceptionsZone.asyncRun (myApp/node_modules/#nestjs/core/nest-factory.js:75:43)
at Function.asyncRun (myApp/node_modules/#nestjs/core/errors/exceptions-zone.js:17:19)
at NestFactoryStatic.initialize (myApp/node_modules/#nestjs/core/nest-factory.js:74:52)
1: node::Abort() [/usr/local/Cellar/node/9.7.1_1/bin/node]
2: node::Chdir(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/Cellar/node/9.7.1_1/bin/node]
3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/Cellar/node/9.7.1_1/bin/node]
4: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/Cellar/node/9.7.1_1/bin/node]
5: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/Cellar/node/9.7.1_1/bin/node]
6: 0x383450a842fd
It turned out that the problem disappeared after deleting and reinstalling node_modules
I am developing a php-mongodb project. I have installed the php-mongodb driver using composer. connectivity is working fine.
used reference link for any guidance :
http://mongodb.github.io/mongo-php-library/tutorial/crud/#crud-operations
and http://php.net/manual/en/mongocollection.find.php
I could not find much reliable theory for php-7 except those.
How to fire a query with php-7 to get a result from database greater than specified number?
The code I tried is :
$rs=$collection->find(['$gte'=>['avg'=>50]]);
this is not working. The error it produced was:
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionException: unknown top level operator: $gte in /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php:180 Stack trace: #0 /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php(180): MongoDB\Driver\Server->executeQuery('training.tbl', Object(MongoDB\Driver\Query), Object(MongoDB\Driver\ReadPreference))#1 /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Collection.php(437): MongoDB\Operation\Find->execute(Object(MongoDB\Driver\Server)) #2 /var/www/example.com/public_html/list.php(5): MongoDB\Collection->find(Array) #3 {main} thrown in /var/www/example.com/public_html/vendor/mongodb/mongodb/src/Operation/Find.php on line 180
found this answer from following here
// search for documents where 5 < x < 20
$rangeQuery = array('x' => array( '$gt' => 5, '$lt' => 20 ));
for above example the answer comes to be:
$rangeQuery = ['avg' => ['$gt' => '50' ]];
$rs=$collection->find($rangeQuery);
I am building a simple extension to display information on a Google Maps with Typo3.
I want to use the following PHP class (http://www.ycerdan.fr/developpement/google-maps-api-v3/) but I can't use it in my Controller.
I tried to use autoloading and require_once in my controller, but I just get PHP or Typo3 errors.
I guess it's a trivial problem, but I can't make it work despite lot of time searching.
Any help or hint are greatly appreciated ;)
General infos
Vendor name : CLICmap
Extension name : clicmap
Class location : Resources/Private/PHP
ext_autoloader.php :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
return array(
'gmaps' => $extensionPath.'Resources/Private/PHP/GoogleMapAPIv3.class.php',
);
How I use it in my controller
public function listAction() {
$maps = $this->mapRepository->findAll();
$gmaps = $this->objectManager->get('gmaps');
$this->view->assign('maps', $maps);
}
The PHP error :
Uncaught TYPO3 Exception
#1289386765: Could not analyse class:gmaps maybe not loaded or no autoloader? (More information)
TYPO3\CMS\Extbase\Object\Container\Exception\UnknownObjectException thrown in file
/var/www/html/ftypo3/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php in line 37.
Trying require_once :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
require_once($extensionPath . 'Ressources/Private/PHP/GoogleMapAPIv3.class.php');
I get the following PHP error :
Warning: Uncaught exception 'TYPO3\CMS\Core\Error\Exception' with message 'PHP Warning: require_once(/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php): failed to open stream: No such file or directory in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php line 52' in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php:101 Stack trace: #0 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'require_once(/v...', '/var/www/html/f...', 52, Array) #1 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): CLICmap\Clicmap\Controller\MapController::listAction() #2 [internal function]: CLICmap\Clicmap\Controller\MapController->listAction() #3 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php(286): call_user_func_array(Array, Array) #4 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/ in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 101
Fatal error: CLICmap\Clicmap\Controller\MapController::listAction(): Failed opening required '/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php' (include_path='/var/www/html/ftypo3-fluid/typo3/contrib/pear/:.:/usr/share/php:/usr/share/pear') in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php on line 52
EDIT : Solved
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.
I want to test a protected method which is inside a controller:
class AuthenticateController extends Zend_Controller_Action
{
protected function getAuthAdapter(){}
}
My test (following this post) look like this:
public function testGetAuthAdapterShouldReturnZendAuthAdapterDbTable()
{
require_once(APPLICATION_PATH.'/controllers/AuthenticateController.php');
$method = new Zend_Reflection_Method('AuthenticateController',
'getAuthAdapter');
$class = new AuthenticateController();
$result = $method->invoke($class);
// assert result value
$this->assertInstanceOf('Zend_Auth_Adapter_DbTable', $result);
}
When I execute the test, I got this runtime exception
RuntimeException: Fatal error: Call to a member function getModuleName() on a non-object in /Users/padawan_rodrigo/Documents/workspace/ZendFramework-1.11.5/library/Zend/Controller/Action/Helper/ViewRenderer.php on line 226
Call Stack:
0.0030 396924 1. {main}() -:0
0.0755 4593044 2. __phpunit_run_isolated_test() -:207
0.0771 4718524 3. PHPUnit_Framework_TestCase->run() -:22
0.0785 4798460 4. PHPUnit_Framework_TestResult->run() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:576
0.3565 4827948 5. PHPUnit_Framework_TestCase->runBare() /usr/local/pear/share/pear/PHPUnit/Framework/TestResult.php:666
0.6696 10508956 6. PHPUnit_Framework_TestCase->runTest() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:628
0.6697 10509780 7. ReflectionMethod->invokeArgs() /usr/local/pear/share/pear/PHPUnit/Framework/TestCase.php:738
0.6697 10509796 8. AuthenticateControllerTest->testGetAuthAdapterShouldReturnZendAuthAdapterDbTable() /project/code/tests/application/controllers/AuthenticateControllerTest.php:0
0.6794 10753940 9. Zend_Controller_Action->__construct() /project/code/tests/application/controllers/AuthenticateControllerTest.php:172
I also tried to mock the class with same results. Any ideas?
Thanks
You need to pass in a request and response to the controller's constructor.
$class = new AuthenticateController(
new Zend_Controller_Request_HttpTestCase(),
new Zend_Controller_Response_HttpTestCase()
);