I am developing a browser based game and i'd like to know which functions take the most time to process and so on.
Does anyone of you guys know what I can start with ? Using PHP 5.3
It sounds like you want xhprof. It excels at profiling.
There's a profiler in XDebug.
There's also one called PHP APD
Related
I want to log what lines per file was run in php. Xdebug can do that, thats all I know. How to do this?
I guess you want a code analyzer, here is a good thread about this
I was asked to help getting a website that was running with 5.2 php code, to work on a 5.3 php server. The site is big, and I can't see the errors that would appear normally when a site isn't working.
I've tried to use the Search and replace function that Dream Weaver has, and simply use it all over the website. But the problem is that I only want to replace functions in PHP documents, and not in js files. When i use Search and replace, in Dreamweaver, it overwrites the js files aswell, and that would cause more errors. Because there's A LOT of files that i have to go through, it would take me a lot of time if i had to go through it manually.
I figured this must be a problem that a lot of firms experiance, so there must be ways to handle this without it being a bigger hassle.
Anybody out there who could help me out ? Any help is much appreciated!
Regards,
Mathias
Check out the official guide about Migrating from PHP 5.2.x to PHP 5.3.x
most existing PHP 5 code should work without changes, but make sure error-reporting is enabled to get some idea of what is going wrong .
I would recommend the use of sed from command line. It is most likely the fastest and most powerful find/replace utility available for LAMP developers.
http://www.grymoire.com/Unix/Sed.html
Dont worry about it! If your code works in php->5 for the most part it will work just fine. 5.3 offers a plethora of options but no doubt your not using them.
I use firebug and smarty so i get good debugging data from that but i'd like to see my database query times and page processing times as well.
Xdebug is very good. It works very well in combination with Netbeans IDE for PHP.
This is a great package to relay data to firebug:
http://www.firephp.org
xdebug is awesome, because it lets you step through code inspecting variables as you go.
It also lets you do profiling (dumps callgrind files into a directory of your choosing, describing in very detailed fashion what happened how many times, when, and how long everything took)
To take full advantage of xdebug, you need a good IDE, i suggest netbeans, but you can use any one of the major packages nowadays.
As linked many times by others, FirePHP and Xdebug are awesome...
But you also asked about page render times and query times.
Unless you're already using a framework that collects this data for you, you're going to need to collect it and set up reporting for it yourself.
Debugging PHP Code on Windows with Visual Studio 2008 or 2010 => http://www.jcxsoftware.com
I'm looking for clean way to break my current habit of using print commands in PHP when I want to see what's happening.
I am aware of options such as Zend Debugger but I use Coda for development and I'm not interested in mixing other software or having to do server commands. I just need a console that can be added to my codebase and then turned on/off.
Does anything like this exist? Furthermore, what do you use and why?
EDIT: There was a lot of stuff out there but I needed something even simpler so I ended up coding it myself. It didn't take long (nor is it very pretty) but I've put it up on my server for anyone else interested.
There is very good extension for Google Chrome - PHP Console.
You can use Xdebug in combination with any one of the many options available to view its debugging info.
There's FirePHP which will write your PHP log messages to the Firebug console.
I am aware of options such as Zend Debugger but I use Coda for development and I'm not interested in mixing other software or having to do server commands. I just need a console that can be added to my codebase and then turned on/off.
Not entirely sure if I understand you there, but couldn't you log to a file and then have a console window running with tail -f /path/to/log-file.txt? That works pretty well for me. Of course, you do need a console connection to the server for this.
Using Coda? That means you are using a mac. You probably want to look at XDebug and http://www.bluestatic.org/software/macgdbp/
There is another extension for Chrome available called ChromePHP. It's a little simpler than some of the other solutions:
https://chrome.google.com/webstore/detail/noaneddfkdjfnfdakjjmocngnfkfehhd
Getting started guide available at:
http://www.chromephp.com
During my development career i have not stumbled upon a software that displays the output you describe in your question. It would be a wonderful program or feature i believe but sadly i have not found any.
Like Andrew and nickf have answered, there are some good tools out there and until someone sits down and writes this, it looks like we are out in the cold.
I was looking for similar solution which wasn't heavy and even better I didn't need to include any classes, so I created simple function that outputs php to browser console, you can check it here:
Outputting PHP To Browser Console
I know there is not a direct way to take a screen shot of a web page with PHP. What would be the most straightforward way to accomplish this? Are there any command line tools that could do this that I might be able to execute from a PHP script (I'm thinking something that would run in a 'NIX OS (OS X and/or Linux in particular)?
Edit: Or maybe some sort of web service I could access via SOAP or REST or ...
Edit #2: I found a related question discussing the CLI option, but I'd still be open to other methods if anyone knows of anything.
See webkit2png for an OSX commandline program that does this.
The page also mentions Linux alternatives.
[edit]: wkhtml2image is the newest kid in town, and it works better then anything else i've ever used.
[edit2]: As of 2014, PhantomJS seems to be the way to go, as it has the newest webkit version of the alternatives I know about.
[edit3]: In 2019, Puppeteer is the way to go. Official headless chrome, always up to date.
You can use the GD functions imagegrabscreen() or imagegrabwindow() to take a screenshot, but they're only available on Windows at the moment.
http://www.thumbshots.org/
html2ps does a decent job for relatively simple pages, and it requires very little in terms of external binaries, meaning it's very easy to install/use. If you control the pages you'll be capturing, then you can ensure that they'll render appropriately in html2ps. If you're hoping to capture arbitrary URLs, however, I'm not sure that the PHP port of HTML2PS is up to the task. It's also not the fastest thing in the world (expect render times in the seconds for complex pages), but that doesn't really matter for some applications.
Not sure if this would be enough for you, because it has some added stuff there, but would be worth giving it a try: http://www.snap.com
It's possible to get a base64 encoded image of a site by using the Google pagespeed api.
You can specify desktop or mobile views, but you are limited to an image of a certain size.