As others have said, a misconfigured web server that treats .php files as plain text will happily serve up your source code.
Most frameworks (both public or in-house) these days, however, keep very little php code in a web-accessible area. Typically, there's a single index.php file in the document root, which includes and calls code in other files that are wholly outside the document root.
Usually, you'll have something like this:
/path/to/proj/ <-- your project root
/path/to/proj/application <-- holds most of your appication code
/path/to/proj/lib <-- third-party libraries go here
/path/to/proj/public <-- your web server uses this as the document root.
/path/to/proj/public/index.php <-- single point of entry into your applicaiton. all requests are routed through here.
/path/to/proj/public/images <-- static resources, like images, also live under the docroot.
Rewrite rules are typically used to marshall any requests through the one public index.php file.
With a setup like this, if your webserver were to become misconfigured in a way that would cause it to transmit your code, you'd be pretty much covered. The only leak would be your index.php file, which is probably a couple of include/require statements, and single function/method call. Nothing sensitive at all.
Look at the standard Zend Framework or Symfony (or any framework, really), file layout, for a clearer picture.