PHP (Zend Framework) Code Profiling on Rackspace Cloud Sites - php

I have an application written on top of the Zend Framework that is hosted on Rackspace Cloud Sites. I want to be able to do code profiling, but I don't know where to begin. The code profiling tools I've seen require installation on the server.
I already use Zend_Log_Writer_Firebug for query profiling, and would like something similar for code profiling. What are my options?

To profile a program, you irremediably need another program loaded in memory, so there is no way to do it "outside".
Xdebug or Zend Debugger allows you to profile your code, and you can set it up to use it remotely, but you still need to install it your server.
You can also take a look at APD (stands for Advanded PHP Debugger) which is part of the PECL.
You could find workaround, or 'PHP' solution, but neither would be accurate or valuable I think.
Anyway, you should not install such tools on live server, however, you can easily install Xdebug through PEAR on your development environment.
The result doesn't need to be accurate, the proportion should remains the same, whatever the env you use.
It doesn't matter if your server is I7 Core Xeon 6Ghz or whatever, and your development server is an old Cyrix K6, when there are bottlenecks, they'll be here and there.

As you are already using Zend_Log_Writer_Firebug , you may have tried zfdebug.
What about xhprofile ? I have not used, but may be good to try :)

Related

Building a CMS in PHP: Development tools

I'm planning to build a CMS in PHP and MySQL, mainly for my own amusement and education. (Though who knows, I may come up with something useful and cool. Anything's possible.) I'll be asking questions about code architecture etc. later. For now, I'm more interested in development tools.
So far, all my playing with code has been done on a web server, and I've edited over FTP. I was thinking it might be quicker to use a localhost. Also, that way, I could use version control (which I've never done before).
So,
A. How do I set up a localhost server with many subdomains on an Ubuntu 9.10 computer. Is XAMPP for Linux the way to go, or should I use a standard Apache distro? (Or another webserver altogether?) For that matter, is it possible to set up more than one webserver on the same computer, and to use them for different localhost subdomains?
B. How do I set up a version control thingy covering all the code (which will be on several subdomains of localhost, and in a few shared folders)? I've read Joel Spolsky's HgInt tutorial, and it makes Mercurial look good. And simple, especially if you're working on your own.
C. Should I continue to use gEdit to write HTML/CSS/JS/PHP, or is there a better free editor out there for these languages?
A. Why would you use XAMPP when installing a LAMP stack is as easy as sudo tasksel install lamp-server? You can add as many domains to the configuration as you want using VirtualHosts for example (well theoretically anyway, in practice the amount will be limited by the available resources), you don't need multiple servers for that.
B. sudo apt-get install mercurial maybe? Of course, how to create a repository and add your projects is up to you - you should read the documentation of Mercurial.
C. Use Eclipse or NetBeans if you're planning to do any serious development work.
I'd recommend against using XAMPP, particularly if you're inexperienced as this would bypass all the package management functionality integrated in Ubuntu (so you need to manually track and apply security changes, if you need extensions not in the XAMPP distro you'll need to compile from scratch, similar for most of the external admin tools which might interact with the Apache install).
Yes - you can have lots of virtual hosts on the same webserver (rcently worked somewhere with 1200 named virtual hosts on each Apache webserver - start up took about 2 seconds rather than 0.5 - but after that you'd never have known the config files were HUGE).
If you're working on your own, then this is about the only scenario where using a distributed version control system offers no benefits over concurrent version control system, and a concurrent version control system offers no benefit over a conventional version control system. But even though it offers no advantage in the technology, it may be of benefit to you to acquire specific product skills.
What editor you use is matter of personal choice. Though personally I would list gEdit in my recommendations (I'd suggest NetBeans or Zend Studio for people who like standalone IDEs, otherwise vim, Eclipse, emacs).
A php documentor is (IMHO) a must (I like phpxref) along with some sort of testing toolkit.
HTH
C.
A: I've used Xampp for Linux successfully on Ubuntu. It's not hard to setup a normal apache installation, but I like the advantage of having a "temporary" web server where the changes are easy to reverse without affecting my normal installation.
If you want subdomains, configure apache to use virtualhosts.
B: I suggest subversion, but VCS is something of a religious issue. It doesn't matter what you use particularly. Once you've made a choice, then research the usage of a VCS.
C: Netbeans is much better than gEdit. That or Eclipse would be my preference. I use Netbeans under Ubuntu myself. A full IDE though will make development much easier than a text editor. Mostly because of code completion/integrated debugger.
I think stackoverflow.com is for programming questions. You'd want to ask those server questions on serverfault.com. Then again, they'd probably ask you to google it. Give it a try.
The editor question is cool. I use Kate, just because it comes with KDE and has syntax coloring.

Is there a true all-in-one solution for PHP Development?

I'm looking for a "SINGLE INSTALLER" solution for PHP Development.
Is there anything out there which will give me a nice IDE, Web Server, Debugger, Database, etc, on a single install image (*.msi or *.exe)?
This of course would be completely opposite of Eclipse PDT, which requires you to search and locate a bunch of additional components which never quite work together.
I think you should go for a separate install for server (web, database) and one for development (IDE, debug) -> Zend or PHPed ?
I think the question is: Does there need to be a true all-in-one solution? I think not.
I agree it's bothersome to have to put dozens of pieces together, but I find a combination of XAMPP, the IDE of my choice, and a few additional bells and whistles (like Polystyle for source code formatting) totally flexible, and not too much work to install.
I don't know if you'll find all of what you're looking for in one package for Windows, but you can get it narrowed down to about two...
XAMPP for Windows comes with: Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.
Then you just need an editor with a debugger, which there are many choices, mostly non-free, such as NuSphere's PhpEd - or free - such as Eclipse PDT or gVim+XDebug+DBGp client.
True one-in-all - not yet. Maybe someone reading this will upload a version.
My tip would be:
XAMPP and Netbeans (The PHP bundle).
2 clicks to install.
3 clicks if you don't have java installed already.
Netbeans is a nice IDE for PHP, too. I use it all the time and I'm much more satisfied with than with Eclipse PDT. It comes in one neat bundle, that you can just install and use right away.
Just download the PHP bundle here
As for a web server, I can recommend XAMPP or Zend Server. They are both easy to install and do a good job. XAMPP has MySQL on board while Zend Server has some really cool optimization features for great performance.
Should it be a requirement that your development environment is easy to install? You're a developer so, you should be able to install and configure a set of (more powerful) tools that suit your specific needs.
You'll only install your bundled IDE once (every so often) so that feature no longer is of benefit when you're developing your projects. It's more likely to become a hindrance as you struggle to configure your environment.
Take a look at Komodo IDE also.
If you're on windows you can get a WAMP package for web,php,database. For IDE I do like Zend Studio 5.5. Not their latest interation based off of PDT. 5.5 has a nice debugger and a built-in web browser that you can view output. The interface is pretty fast, running your code through the debugger/browser is slower than on a real webserver, but ofcourse you get the nice perks of breaking,inspecting your code. The only drawback is that Zend Studio 5.5 is not supported anymore and the highest PHP version that works with it is 5.2.13.
Currently though I have a Virtualbox Ubuntu Server image that mirrors my production enviroment, except it has Samba installed so I can easily copy files back and forth.

what are the Advantages and disadvantages of running php on windows

the linux environment is natural to php,
what are the Advantages and disadvantages with run php on windows ?
Are there some limits in windows ?
what is the best (lamp/wamp) in term of performance ?
thanks
It's not so much that it is natural on Linux but the tendency was for developers to use PHP in the earlier days as the ASP on Linux. For years MS never even mentioned PHP and never gave it any support and so most development work happened in the Linux arena with the result that it is more advanced as it has simply had more development hours spent on it.
Again in the early days it was more difficult to get PHP running on ISS but apache makes it easier but then you need to install it. I rarely develop on Windows but i think the environment has changed for the better with more integration.
The emergence of packages such as XAMPP and WAMPP make installation and running a lot easier but as Karsten says not really for the production environment as they are not geared for it in performance and especially on the security level, because of this i also doubt if they are geared for performance, they are geared for ease of install and development.
Case sensitivity can be a problem if you develop in Windows and later move to Linux.
Well, there's the obvious problem of trying to compile PECL extensions on a Windows platform, and the problems associated with not having sendmail running and trying to use the mail function.
Other than that, as long as the source has been ported correctly, it should do fine.
There is an Site from Microsoft for this http://php.iis.net/
For good Performance also check out http://www.iis.net/expand/fastcgi
I can't give you performance statistics. Would guess that an extremely stripped-down version of Linux or BSD is best from that standpoint.
There are two main disadvantages of Windows. One is that you're likely to have to build some of the lesser-used extensions yourself, if you need them. (There are Windows builds of the common stuff - APC, etc. - available on the net for 32-bit, though. For 64-bit Windows... well, it's a jungle out there.) The other is that you're going to be in the minority, so expect all the things that go hand-in-hand with that. (If you run into configuration difficulty, for example, there will probably be fewer people able to help you.)
The advantage is that (especially if your favorite IDE is something like Visual Studio) you can run all your favorite Windows stuff on the machine. This is really only an advantage if this is, say, a development box - something you're going to use for other purposes as well, not just as a server.
If you are working in an windows environment, running your application/php scripts there makes a lot of sense if you want to debug locally.
I wouldn't use WAMP for production environments, because its nature is in linux imho.
XAMPP solves the sendmail issue amphetamachine is talking about by installing mercury mail.
It also comes with prebuilt xdebug, apc and memcache modules, which are for me the usual pecl compiled extensions.
An obvious problem with PHP on Windows/Apache is not being able to configure PHP APC for current versions of PHP. Hence, no way to create elegant file uploads with progress bar.
Most and main PHP developers (I mean, those that create the language) seem to work under Unix platform. Also, almost all Linux distros take care of building, packing and fixing PHP to suit their systems. And this also applies to auxiliary software like Apache. As a result:
There's always some functionality that doesn't work on Windows, e.g. strptime() or has more bugs.
Windows binaries are not optimized for your system. You can't even get 64 bit binaries unless you compile them yourself.
The MSI installers are not as polished as they should.
Installing PECL extensions is very complicate since there aren't official DLLs.
Of course, there's also Windows-only functionality in PHP, such as Windows only extensions or third-party extensions like the Microsoft SQL Server Driver for PHP, or functionality that's way easier to use under Windows, such as ODBC.
Talking about performance itself, it's difficult to make a fair comparison. The operating systems themselves have very different hardware requirements and it'd be misleading to compare optimized Unix builds with generic Windows binaries. My intuition says that the decision of choosing either platform should be based in other considerations, such as budget, required features or ease of maintenance.
There are many quirks across platforms with PHP, and I don't recommend switching between LAMP / BAMP / SAMP and WAMP / WIMP.
For one thing, permissions are completely different -> usually being a lot harder to work with in Unix/Linux (as Windows doesn't seem to care all that much about permissions as far as I have ever seen). This is a good thing, in my opinion, though (I'm relatively safety paranoid).
Here are a couple more things that differ:
http://php.net/touch (could't change windows directory modified times until 5.3)
http://php.net/flush (still can't flush or ob_flush from some win32 machines)
Both have system specific issues that were just SUPER recently worked out or haven't been fixed yet...

Installing Zend Server on Production Server/Machine

Hello i was wondering if anyone had to install/or is working with Zend Server.
My Question is: If i install Zend Server on a production server will it mess up my existing PHP configuration? Will i have to bring my application offline first or will Zend Server install without problems?
The application must run 24/7 and i need a reliable PHP Stack that will boost performance. Any comments on the performance part of Zend Server? Does it worth the installation?
Thanks,
That's no way to think about handling a production server.
I'm not experienced with the Zend Server product, but I wouldn't just install anything on top of a running production system.
Instead, get yourself a new server that will eventually replace your production server.
Then:
Start with a clean install of your distro of choice.
Install ZS (take notes on exactly what you do)
Install your application and data (take notes on exactly what you do)
Test it thoroughly.
If it works, nuke the server, and repeat 1-4, using your notes.
Once you're satisfied that you can get everything working "from scratch" using your notes, create a plan to migrate from the old server to the new one.
Doing it this way ensures that
You have minimal downtime.
You don't have some mess with ZS installed over the top of some other set up.
You can re-build your server when necessary (you created documentation)
2016 Edit: These days, there are various tools such as chef, ansible, or salt that replace obsessive note-taking with automation. I highly recommend anyone managing production systems learn one or more and use them liberally.
When Zend Server is installed on Linux boxes, it will replace the PHP packages supplied by the distribution, and some other packages which supply some PHP functionality. As tim said, it is better for you not to replace the production server environment on the first round, as not always things will work as expected, even to the advanced users.
Take another machine with similar environment and make it your staging/development environment. This will allow you to play with Zend Server features without actually taking down your production server and sites. At the moment you are sure everything works as expected, and only than, start thinking about changing your production site.
To run multiple LAMP servers on Ubuntu, I use XAMPP for Linux and Bitnami LAMP Stack .
By default, the first works on port 80, the second on 8080. Hence they don't conflict. If you know a little about Apache configuration, and if can write a few simple scripts, you can do many things.
However, doing anything on a production server is dangerous.
Both XAMPP and Bitnami stacks are meant to be development environments.
See timdev's answer, +1 to that.

Using Xdebug & Zend Debugger Simultaneously?

Is it possible to run both debuggers within the same PHP installation simultaneously. They both use different ports so communication with the client IDEs/other apps wouldn't be an issue.
I ask only because using the Zend Debugger with ZendStudio has proven to be much easier (fewer steps to start/stop debugging from the browser), but I really like some of the profiling tools available that only work with XDebug. So in a nutshell, I would love to be able to have the best of both worlds if possible.
http://www.suspekt.org/2008/08/04/xdebug-203-stealth-patch/ (in particular the last comment) seems to indicate that the profiling parts of Xedebug will work fine alongside Zend Debugger, with the patch installed.
It is possible - the simplest way on a development web server would be to run 2 different apache processes with different php.ini files referencing the different debugger modules
So, XDebug is known not to work with many Zend tools (I know Zend Optimizer for certain, I don't know about Zend Debugger but I wouldn't be surprised if XDebug has a built-in check for that).
Since you're running the debugger and profiler on a dev machine, I don't see why you can't maintain two separate ini files. Otherwise, you'll have to compile a custom version of yourself that bypasses the checks.

Categories