I'm trying to move a php/mysql web application to a new server. The application runs fine on multiple other servers, just not the one the client wants it on. Problem 1 is I can't get errors to display on screen or in an error log. (I've posted a separate question about this). I'm hoping if I can get error to display I'll have more to go on, but what I know so far is it fails when trying to extend a module. I stripped down the class to just this:
class Module_Organization extends LmsModule {
function Module_Organization($module_name = '') {
die('Made it into the function');
}
}
Nothing happens. But if I change it to:
class Module_Organization {
function Module_Organization($module_name = '') {
die('Made it into the function');
}
}
then it does execute the die statement. So it seems that the extend portion is tripping it up. But I don't think it's the code because I know this exact code works fine on other 5 other servers. So I'm wondering if there is any server configuration that could prevent php from extending a class.
Thank you in advance for your help.
I compared the php.ini file to a server where it is working to make them match and it is now working. I'm not sure which changed fixed it though. Thank you.
Related
I have this controller
class APIV1CustomerController extends BaseController{
public function getIndex(){
return "super new look";
}
public function postRegister(){
return "you have entered "+Input::get('fullName')+" as fullName parameter and "+Input::get('mobileNumber')+" as mobileNumber parameter";
}
}
I am trying to call the register function from IOS, I have some problems with the returing data. Thus, I need to debug that function.
when I return just simple test like return "test", it works well from IOS. but when I return the code I showed to you, some problem accrues, I can solve the problem myself from the IOS side but I need to debug the postRegister to check some issues.
when I was using J2EE web service, I can simple print some data to the console in my eClipse that is why I am asking if there is any way to do that in laravel.
Thanks
I am using php storm IDE
This might be useful: https://github.com/mlanin/laravel-api-debugger
It's a laravel package specifically built for assisting with APIs.
this might be irrelevant, but i learned a lot from this article when debugging api and jquery back then. http://www.openlogic.com/wazi/bid/188084/jQuery-and-Ajax-Error-Detection-and-Handling.
the first step is to see if there's any functions in your IOS which will notify you when you have an error after the http call, so that you know you actually are getting an error, ex. 404, 500 etc. Because if you are getting 200, most likely you don't need more advanced debug tool other than print.
server log is another friend which is very helpful in these white screen case, it'll tell you the exact error when 500 error happens. Ex. last error I got on my server was telling me a class name is not found, although it runs fine in my local.
I am in the process of migrating a site from my personal dev server onto Windstream's business hosting server. I've already run into the issue of having developed using PHP 5.4 only to find out that my static functions won't work on WS's 5.1.4 installation. I've since fixed those issues and am not facing one that I can't seem to find any help for on the internet.
All of the static functions I was using have been rewritten as functions outside the class scope. Instead of having
class Product{
...
public static function myFunction(){}
...
}
I now have
function myFunction(){}
class Product{...}
in my included Product.php file.
However, when I try to call myFunction() from my code, nothing happens. I know the nothingness comes from WS's error handling, but the point is, the function isn't working. To verify this, I have taken the following steps:
Inserted the line echo "entered included"; immediately following the <?php in Product.php. This prints "entered included" on the index page, indicating that my include is working. I have done the same thing before the final ?> with the same results, so I don't think it's getting hung up inside the included file.
I have changed myFunction() in the included file to be simply
function myFunction(){echo "myFunction works";}
A call to myFunction() still makes nothing happen.
I have moved myFunction() to the including file (myFunction() now lives in index.php instead of Product.php; index includes Product.php). This time, myFunction() executes without issue.
To my 'hack it til it does what it should' sensibilities, this tells me that the server is having a problem with functions that are declared in files that are included; honestly, though, I have absolutely no clue what's going on, and any help would be appreciated. Their website is currently down, and they were expecting it to only be offline for a day, so I'll try pretty much anything short of sacrificing a fatted calf.
I know I should be posting more specific code, but since this is a customer's actual website, I'm trying to put as little of the actual code out here as is possible. I'm happy to append specific sections of code to this entry as they are requested for clarification.
Thanks in advance for your consideration.
#Rottingham: First, thanks for the 3v4l link. Second, my assumption about static methods in 5.4 vs 5.1.4 came from this line of php.net's page on static members and methods:
"As of PHP 5.3.0, it's possible to reference the class using a variable. The variable's value can not be a keyword (e.g. self, parent and static)."
src - http://www.php.net/manual/en/language.oop5.static.php
Since my version and the server version were on different sides of the 5.3 mark mentioned, I incorrectly assumed that this was my problem.
Third, when I get in from my day job, I'll update my code to show errors and update this post if a solution has not yet been found.
Ultimately, my problem isn't with using static methods (since I don't have them anymore) but with using any function that is declared in an included .php file.
I was following documentaion till the end, tested one html template with smarty and then cut it. Then I found out that controllers do not work as expected – whatever name I create in myapp/conrollers, 'hello.php' for example, that contains class described in docs, i. e.
class Hello_Controller extends TinyMVC_Controller
{
function index()
{
echo "Hello World.";
}
function time()
{
echo "The time is now.";
}
}
I can’t show it. So the name of the file is a prefix for the controller class name, all seems to be ok here, but going to /index.php/hello returns what is in 'default.php'. I’ve even tried to change default controller to 'hello' in myapp/configs/application.php by setting $config['default_controller'], but the framework behaves like if it’s always work with the 'default.php'. There is no errors on screen or in logs (I checked twice every option in configs of my web server and interpreter), I totally don’t know what to do with that goddamn piece of crap, I can’t even write on its forum because waiting for ‘administration approval’ for several days.
I had to dig inside of the framework to find an answer. And it is when it checks for a controller file it uses file_exists() which do not respect include path. Googling ‘TinyMVC+file_exists’ gave me link to that topic, where is written that they had fixed it in SVN version.
I'm setting up my cron job controller that will only run within the CLI, I've not started with anything built, just in the testing phase with CI's examples. However, when running it I get no output or anything else, just a new line, this is the command I ran:
root#serv$ php /var/www/ci/index.php tools message
root#serv
As you can see in the second line, I get no output, just a new line to run an command but I don't understand why and I cannot debug it. The code contains this:
<?php
class Tools extends CI_Controller {
public function message($to = 'World')
{
echo "Hello {$to}!".PHP_EOL;
}
}
?>
In my configuration file, the $config['uri_protocol'] is set to AUTO so this does not seem to be the problem.
How can I debug this? What are the options that I may need to deal with?
I also have display_errors on and error_reporting on to E_ALL.
I found the problem, it was a problem with a redirect('domain.com'); exit; I had on an autoloaded library, because it was matching against the domain in a database, that way CLI doesn't serve a domain when it detects, hence I included a redirect('domain.com') with an exit which is why I'm not seeing any output.
I also encountered this while i was playing w/ cli for codeigniter. It took me a while to troubleshoot the issue and found out that I forgot to except my controller on my login model which runs a redirect function.
This may be a silly suggestion, but might as well give it a shot... #lolwut, what if instead of using "echo", maybe you have to "return" the output?
I have an application following this guide: http://codeigniter.com/wiki/Category:Advanced::CronScript running (and producing output). CI was only 1.7.2 when I did so, but it might still hold
(CodeIgniter 2.2.0)
Add a route in /application/config/routes.php
for...
<?php
class Cron extends CI_Controller
{
public function process_dumps()
{
echo "Processing dumps..." . PHP_EOL;
}
}
?>
add...
$route['cron/process_dumps'] = 'cron/process_dumps'
Without this line there was no output on the CLI!
I think you can find the answer in the Codeigniter Wiki.
By calling to the cron.php with parameters controller and function, and then define CRON_CI_INDEX to the refer to the file path of your main index.php.
For example,
php /var/www/ci/cron.php --run=/tools/message
I got a PHP web service that had been running great for a long time, but somewhere a long the way it some how stopped working, and I just can't get it to work again.
I got some php page in which all I do is define a class with functions, and in the end of it I create the SoapServer.
It looks like this -
class MyClassWS
{
function .....
function ....
}
ini_set("soap.wsdl_cache_enabled", "0");
error_log("Server after ini_set");
$soapserver = new SoapServer("MyWSDL.wsdl");
error_log("Server after new SoapServer");
$soapserver->setClass("MyClassWS");
error_log("Server after setClass");
//error_log(print_r($soapserver->getFunctions()));
try
{
$soapserver->handle();
}
catch(Exception $ex)
{
error_log("Exception!".$ex->getMessage());
}
error_log("Finished Handling",0);
Right after the $soapserver->handle(); the code terminates, and I get a vague "SOAP-ENV:ClientBad Request" result on my web page.
This happens when I "require_once" this page, from my index page, so I could call functions that are defined in this class, from my index page.
My guess is that maybe I've been fiddling too much with my WSDL and somehow it screwed up my while WebService, but I tried looking on what's wrong with it, but couldn't get onto anything. Especially because of this annoying vague error message, that doesn't really help.
Thanks!
I think I nicely fixed it by separating the WebService class that included the SoapServer into 2 different classes.
One that included only the class with the functions, and another that included the WebServer and only had a reference to the class.
This way I can import the class with the functions without also importing the SoapServer and triggering the handle() function.