UndefinedMethodException in appDevDebugProjectContainer.php line 1606 - php

I'm somewhat lost what I've done here. My app was functioning for a while, and at some point I changed something that caused this error. I've cleared my dev cache. At some point I wonder if I updated my composer and caused something because I wasn't even touching the php side of my app when I broke it.
Here's the full error:
UndefinedMethodException in appDevDebugProjectContainer.php line 1606:
Attempted to call an undefined method named "AddAthlete" of class "FOS\RestBundle\Util\FormatNegotiator".
That particular function looks like this:
protected function getFosRest_ExceptionFormatNegotiatorService()
{
$this->services['fos_rest.exception_format_negotiator'] = $instance = new \FOS\RestBundle\Util\FormatNegotiator();
$instance->AddAthlete($this->get('fos_rest.request_matcher.0dfc4cce134bee15f08405cb5cea4845b13ff7d8c8f779004218432a2c552bd0cd9f9d27'), array('priorities' => array(0 => 'html', 1 => 'json', 2 => 'xml'), 'fallback_format' => NULL, 'prefer_extension' => '2.0', 'methods' => NULL, 'stop' => false));
return $instance;
}
I'm not particularly familiar with how this gets generated. Could someone help? If needed, here's a link to my bundle on github

Turns out I must have had some composer issues because when I pulled the repo down to my other machine, it worked fine (with the exception of new bugs, yay!)

Related

Returning Three Dimensional Associative Arrays with PHP

I suppose I am a noob with PHP so apologies if I sound dumb, but, I do have a troubling dilemma, I have spent the last six hours plus scouring Google for any hints and found none so here I am on the SO forum looking for some 'pointers' in the right direction.
I have an issue with returning 3DAA's from a function in a class to other parts of my code and no matter what I try I'm getting a null value back, according to the error log anyway, but when I run this code separately from the framework, in a single file using the same declarations it miraculously starts working and echos the specified part of the array to the screen wahey, but I don't know why it suddenly works nor why it won't work in the framework and supplies a null value.
I was wondering if anyone out there has experienced such weird errors with returning 3DAA's and if so, how they got around it. If you want to see the code ask and I'll post it.
<?php
class Core {
public function GetConfiguration() {
$configuration = array(
"cobalt" => array(
"name" => 'Cobalt',
"version" => '1.0.7',
"directory" => array(
"root" => 'application',
"modules" => 'application/modules',
"html" => 'application/html'
)
),
"application" => array(
"name" => 'Cardinal Technologies',
"version" => '1.0.2',
"server" => 'http://localhost',
"seo" => array(
"copyright" => 'Ida Boustead',
"description" => 'Welcome to Cardinal Technologies, here at Cardinal Technologies we pride ourselves in providing the best possible customer service whether you need a repair or upgrade for a computer, android phone or tablet, even alarms and CCTV',
"keywords" => 'computer repair,computer upgrade,computer upgrades,android phone repair,phone repair,android tablet repair,tablet repair,alarms,cctv,network installation,network install',
"robots" => 'index,follow'
)
)
);
return $configuration;
}
public function LoadModule($module) {
require_once 'application/modules/' . $module . '.class.php';
}
}
?>
Hope this helps.
I'm calling it like this.
require_once 'application/Core.class.php';
$core = new Core();
$configuration = $core->GetConfiguration();
and getting an array value like this.
$dir = $configuration['cobalt']['directory']['html'];
the prior is a snippet from a larger file but this is what relates to that function.
I get PHP Notice: Undefined variable: dir in the log which is what led me to believe the function was the problem.
If I echo $dir it echos application/html which is what it's supposed to, but it is not usable for anything other than echo which is pointless to me as I need that value to make other parts of the framework work.
Right it was me being a dumb dumb, I put the declarations in the wrong place, outside of the class and it did not like it.
I moved them to inside of each function that stalled the code and it fixed that issue. Thanks anyway.

Laravel Dusk not running behing proxy

Overview of the problem
I am trying to get started with Laravel Dusk, however, I cannot get it to run correctly. Based on the feedback from when I run it in the console and some google searches and the fact I'd experienced the same issues with a similar package before Dusk was released I am guessing the issue is down to being behind a proxy at my work-place. I could of course be wrong about it being about the proxy but it's the only thing I have to go on for now. If I'm honest I don't even understand why it needs to know my proxy settings for running local tests locally?
Set up
Windows 7 64bit
Laravel 5.4.15
Dev env: Laragon
PHP 7
Dusk Installation
I did the following to install dusk:
composer require laravel/dusk
Set the following in .env: APP_URL=http://ticket.dev
Added the following to my AppServiceProvider register() method:
app/Providers/AppServiceProviders.php
use Laravel\Dusk\DuskServiceProvider;
//...
public function register()
{
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}
Running Dusk
When I run php artisan dusk, I get the following in my console:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.
Error code: 4
The response: '<!DOCTYPE html>
<html>
<head>
<title>Laragon</title>
// the rest of the output is what http://localhost produces
So it appears to be hitting http://localhost and not my APP_URL?
Attempted solutions
I found this github wiki page and after browsing through the vendor folders related to Dusk I tried setting the proxy when the driver is set up in the driver() function in the file tests/DuskTestCase.php.
I've tried the following, but I get the same console output as mentioned before:
protected function driver()
{
// same as DesiredCapabilities::chrome() except with proxy info
$capabilities = new DesiredCapabilities([
WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::CHROME,
WebDriverCapabilityType::PLATFORM => WebDriverPlatform::ANY,
WebDriverCapabilityType::PROXY => [
'proxyType' => 'manual',
'httpProxy' => 'http://proxy:8080',
'sslProxy' => 'http://proxy:8080',
],
]);
return RemoteWebDriver::create(
'http://localhost:9515',
$capabilities,
);
// original code after installation
// return RemoteWebDriver::create('http://localhost:9515', DesiredCapabilities::chrome());
}
and ...
protected function driver()
{
$capabilities = new DesiredCapabilities([
WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::CHROME,
WebDriverCapabilityType::PLATFORM => WebDriverPlatform::ANY,
WebDriverCapabilityType::PROXY => [
'proxyType' => 'manual',
'httpProxy' => 'http://proxy:8080', // have also tried without specifying http://
'sslProxy' => 'http://proxy:8080', // have also tried without specifying http://
],
]);
return RemoteWebDriver::create(
'http://localhost:9515',
$capabilities,
null,
null,
$http_proxy = 'http://proxy', // have also tried without specifying http://
$http_proxy_port = '8080',
null
);
}
Any help on getting this working would be appreciated, thank you!

Using Mango within a unit test in Kohana

So I'm switching our application to use Mango rather than the built in ORM within Kohana. I've switched over all the necessary application code to work as expected, but when our CI server runs through our unit tests, I get a "Class 'Mango' not found" error.
Tests provided are dumbed down, but the style I use in the UnitTest is exactly the same way I use them in a regular GET request. It works when I do a GET, but the unit test fails. Now hopefully unrelated, I cannot reproduce this locally, but can't ever get the unit test to work on our CI server.
My guess is that I'm not loading the module properly, but like I said, it works correctly in the application and only my unit tests are failing (with FATAL ERRORs).
application/classes/Model/User.php
class Model_User extends Mango {
protected $_fields = array(
'user_id' => array('type' => 'string', 'required'=>TRUE),
'first_name' => array('type' => 'string', 'required'=>TRUE),
'last_name' => array('type' => 'string', 'required'=>TRUE),
);
}
application/tests/UserTest.php
Class UserTest extends Unittest_TestCase
{
public function testUserCreation()
{
$user_data = array(
"user_id" => "1234asdf",
"first_name" => "Test",
"last_name" => "User",
);
$new_user = Mango::factory("User", $user_data);
$this->assertEquals($user_data, $new_user->as_array());
}
}
EDIT: Here's a link to the Mango module I've brought in: https://github.com/Wouterrr/MangoDB
If anyone stumbles upon this via google, I solved the issue. It appears as though our applications nginx config handles capitalizations more nicely than the CLI. Upon changing "Mango" to "mango" I saw the error message change to not finding it's parent class (for the same casing reasons). While I imagine I could have just changed all the casing, Kohana has a function for casing issues, so in application/bootstrap.php, you just have to run both of the following:
spl_autoload_register(array('Kohana', 'auto_load'));
spl_autoload_register(array('Kohana', 'auto_load_lowercase'));

how to install SmallFry MVC Framework under Xampp

How to install and use SmallFry framework.
I downloaded it from https://github.com/maniator/SmallFry
Extracted it under htdocs and placed all content in folder: smallfry (C:\xampp\htdocs\smallfry).
Set Doc root to define('DOCROOT', 'C:/xampp/htdocs'); in Autoloader.php.
Changed db info to following settings---
$CONFIG->set('DB_INFO', array(
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'smallfry',
));
Still getting the following error --
let me know what else need to be change as i m very new to this framework.
Apparently, the framework is a bit out-dated, as assigning the return vlaue of new by reference is indeed deprecated. You should look for $x =& new Obj; calls and remove the &.
The Fatal error should be fixed after fixing the other issues. According to the documentation, that method should exist.
Fatal error occurs due to first two errors.
Because of Deprecated warnings Config class wasn't loaded correctly.

Why is frontend of Magento site not loading up? - Fatal error: Class ‘Mage__Helper_Data’ not found

I’ve got an issue with the front end of a magento site, it is throwing a 500 error. The back end admin is absolutely fine and functional, I'm able to log in no problem and there is no loss of product data.
I have un-commented out line 70 in my index.php file -
#ini_set(\'display_errors\', 1);
in order to see the errors, and this is what now displays when you load up the front end of the site - Fatal error: Class \’Mage__Helper_Data\’ not found in /var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/app/Mage.php on line 520
I reckon the double underscore here is to do with a module being missing or something..
This problem came to light after I refreshed all cache types in the admin area, but I suspect the problem was there beforehand but just bared it’s head after the cache refresh.
So far I have tried/checked -
deleting the contents of var/cache, var/session
The base URL in the db is correct
made all directories 755 permissions, and all files 644, I have also tried making index.php 755, and 777 on suggestion from other forums.
checked htaccess, all seems fine.
the physical files are all there on the server.
system.log seems to be consistently pointing to line 93 in Autoload.php -
2011-09-12T15:18:52+00:00 ERR (3): Warning: include() [<a href=\'function.include\'>function.include</a>]: Failed opening \'Mage//Helper/Data.php\' for inclusion (include_path=\'/var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/app/code/local:/var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/app/code/community:/var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/app/code/core:/var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/lib:.:\') in /var/www/vhosts/beta.mydomain.com/httpdocs/countrytoys/lib/Varien/Autoload.php on line 93
Other things I can think of that I have recently done include adding google analytics through admin, altering the code for links at the top of the site in app\design\frontend\default\blue_toys\template\page\html\header.phtml and entering some paypal details in order to set up the payment gateway.
installation details -
ver -1.5.0.1,
Theme - custom installed theme
Can anyone help?
thanks,
Luke
Your error message shows two underscores between Mage and Helper, where there usually is only one of them. For me it looks like you lost a word between Mage and Helper somewhere, as usually Mage helper identifiers are s/t like Mage_Core_Helper_Data.
I'd check the <helpers> sections of my /etc/config.xml files for wrong definitions first.
Other than that I'd probably try to get a debug trace inside the Varien_Autoload::autoload method.
I'd lookout for patterns in the parameter $class which could result in s/t like Mage__Helper_Data, e.g. occurences where $class contains spaces or double underscores:
public function autoload($class)
{
try {
if (strpos($class, ' ') !== false || strpos($class, '__') !== false) {
throw new Exception('fishy');
}
}
catch (Exception $e) {
var_dump($class, $e->getTraceAsString());
die('stop');
}
// original method code starts here
// :
}
I had a similar problem, and this question appeared in the Google results, so I thought it would be sensible to add an answer here for anyone else struggling with the same problem. With my issue, it was related to a custom <source_model> I was trying to use in the Magento configuration system.
I used the example code from Magento, which looks like this:
public function toOptionArray()
{
return array(
array('value' => 0, 'label' => Mage::helper()->__('First item')),
array('value' => 1, 'label' => Mage::helper()->__('Second item')),
array('value' => 2, 'label' => Mage::helper()->__('third item'))
);
}
The error was coming from the Mage::helper() bit - no helper was being loaded. You can change it to this, or load a specific helper:
public function toOptionArray()
{
return array(
array('value' => 0, 'label' => 'First item'),
array('value' => 1, 'label' => 'Second item'),
array('value' => 2, 'label' => 'third item')
);
}

Categories