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.
Related
I'm trying to build a PHP RESTful service using PhalconPHP. I'm new to PHP, so this may be a beginner question. I am following a tutorial https://www.toptal.com/phalcon/phalcon-php-restful-apis, and in the tutorial there is a section where it makes a call to pull the list of users.
public static function find($parameters = null)
{
return parent::find($parameters);
}
I am passing in a list of parameters listed below.
Array
(
[conditions] =>
[bind] => Array()
[columns] => users_id
)
but I keep getting a 500 error. I'm fairly sure it has to do with how I am connecting (or in this case, NOT connecting to the database).
I'm not 100% sure on what the 'parent' part does either, nor how it connects up to my MySQL database - I think I've gotten the config setup, and I've passed in the tablename that I'm expecting it to be under, but I have no idea if it's actually connecting up and then failing, or if the call itself is failing. So far I've tried echo and print_r with as many variables as I can find, but so far I'm not getting any information on why this is failing.
What is a good way to go about troubleshooting this? How can I find out what the 'parent' is? How can I find out if I'm connecting to my database even, or if it's failing before then?
In your concrete example, the quotes are missing in your conditions and columns parameters, it should be:
$users = Users::find(
[
'conditions' => '',
'bind' => [],
'columns' => "users_id"
]
);
Which should return a list of users ids (if any).
That tutorial from Andrew Belousoff is very good but maybe the next step after Phalcon's REST tutorial, since it explains step by step the inner workings of Phalcon.
For debugging, you can also check Phalcon's guide about it: https://docs.phalconphp.com/en/3.4/debug
And after Belousoff, you can dive into deeper waters with this one: https://github.com/phalcon/phalcon-api
Error 500 means error in php, just check logs. Im not sure how this parent thing is related to phalcon. This is just OOP, you mean you are using framework without knowledge about php/oop? Parent is just parent class which you extends.
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!)
I want to make my website payments via sagepay. The problem is I am not able to locate all the things in the PHPKit they provide. The version of the kit is 3.0 and I want to configure iframe integration but when I open the test method there is this piece of code
$view = new HelperView('server/low_profile');
$view->setData(array(
'env' => $this->sagepayConfig->getEnv(),
'vendorName' => $this->sagepayConfig->getVendorName(),
'integrationType' => $this->integrationType,
'request' => HelperCommon::getStore('txData'),
));
$view->render();
I want to locate those keys 'env', 'vendorName', 'integrationType', 'requests' and see how to put them to use in my system. I see this syntax in a lo of places
public function setSagepayConfig(SagepaySettings $sagepayConfig)
{
$this->sagepayConfig = $sagepayConfig;
}
But I don't know what SagepaySettings means and how to trace it. Can you tell me where can I find SagepaySettings, or what does this mean. Is it a class or method or attribute, because I cannot find it in all the files as any of those.
It's a class in \lib\classes\settings.php
I want to add a column in order grid whose value come from another block.
The code I used in Grid.php are as given below :
$this->addColumn('sum_total', array(
'header' => Mage::helper('sales')->__('G.T.Used'),
'column_css_class' => 'a-right',
'type' => 'currency',
'currency' => 'base_currency_code',
'renderer' => 'Marketplace_Mpshippingmanager_Block_Adminhtml_Sumtotal'
));
Here is the code used in block :
class Marketplace_Mpshippingmanager_Block_Adminhtml_Sumtotal extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function input_render(Varien_Object $row)
{
//echo '$'.(float)($row['base_subtotal']-$row['base_grand_total']);
printf("$%.2f", ($row['base_subtotal'] - $row['base_grand_total']));
}
}
It work on localhost but make problem on server.
why?
If some one help is more appreciable.
Is localhost windows? Server Linux? I can't say for certain but I ran into this earlier in the week turned out Windows is case insensitive and Linux is case sensitive. The Varien Autoloader which parses all classnames and strings was throwing in '\' where I didn't want them and magento could not find my files.
I do not know if this helps but, it was so similar to my problem I figured I would put in my 2 cents. Here was my thread with the problem explained by a much smarter person. https://stackoverflow.com/questions/30085012/magento-mass-action-grid-does-not-update
So I've got a bug somewhere in my code that stops certain elements from being included in an array, this is the best way that I can explain it.
I've got a static file (Config.php) that contains a large array full of data, within this array there is another array with a key of "PredefinedValues", this contains values that need to be referenced by other parts of the script.
The issue: I can reference everything in the array except for 5 values that I recently added, I var_dump the array and they're not there when they're clearly in the file. I've reuploaded the files to my web server around 5/6 times, restarted php, restarted the server and it's not fixed. The issue does not occur on my local machine (Windows) but it does occur on my Linux server (Ubuntu).
The array is structured like this:
<?php
global $Configuration;
$Configuration = array(
"PredefinedValues" => array(
"Example" => "example",
"123" => "test",
"abc" => "test2",
"asdf" => "value2",
"val2" => "value3",
),
And the values I wouldn't be able to access are abc/asdf - but all of the values above/below it are fine.
Init file:
require_once("config/Config.php");
Class Lib
{
Public $Root = __DIR__;
Public $DependencyRoot;
Public function __construct()
{
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(E_ALL);
Global $Configuration;
var_dump($Configuration["PredefinedValues"]);
$this->DependencyRoot = __DIR__ . "/libs/Dependencies/";
}
}
?>
Var_dumping the array within the __construct doesn't work, but when I var_dump it straight after the require, it works fine.
Any ideas? Help would be greatly appreciated.