Drupal6 - Debug on the page
Hi
I am going to change the template file (page.tpl.php), I need to write the code on this file, then upload to server, after that refresh the browser to see开发者_JS百科 the result.Is there any other way to do this thing conveniently?
Most people set up a test server on their local computer so they can edit it directly, then upload to the real server when you're done.
If you are using Ubuntu (or any modern Gnome or KDE-based linux-system) you can very easily "mount" remote servers over FTP or SSH (or a range of other protocols).
That allows you to work directly on remote: open files with any editor, save it, as if it were a local file and so on.
http://blog.ashfame.com/2011/01/connect-ftp-server-ubuntu-without-client/
That is a good way to develop, if your development environment is set up remote. However, developing on your live environment is generally a bad idea:
- It opens up security issues: the unfinished, unhardened environment is accessible to anyone. Just leave some development-module on and your server could de taken over, for instance.
- It is cumbersome: a local development-environment allows for much more convenience addons, such as verbose logging, debug-addons and so on.
- It is (near) impossible to cleanly continue development after deployment (putting live), since you will be debugging amongst your visitors: giving them errors, breaking their accounts, and so on.
On Windows Xampp is a good choice: http://www.apachefriends.org/de/xampp.html
Please note if you are on 64bit Windows machine you cannot debug. Xdebug nor ZendDebugger are working with the any of the xampp versions.
See also the Drupal for Firebug extension - https://addons.mozilla.org/en-US/firefox/addon/drupal-for-firebug/ - to use this, you must also install the Drupal module on your Drupal site, from the source linked there. This will give you easy access to the content of variables by simply including in the template file (between PHP tags) firep($myvar);
This will add to the convenience - the variable dump won't be in the middle of a lot of HTML, sometimes obscured - but will be nice, cleanly displayed in the Firebug panel at the bottom of your browser.
If you have shell access to the server, you can edit the file via vi or emacs. If you do not have shell access, there are text editors out there that can treat remote files like they are local. My personal favorite is Ultraedit.
I suggest you to setup a local development server using the *AMP stack ( LAMP for linux, MAMP for Mac OS or XAMPP for Windows ) server, so that you are able to quickly edit and test files.
Also usually is not advised to directly develop on a production system, as you could produce service downtime due to your developing.
Some useful resources you can find are:
- Quickstart: Prebuilt Drupal Development Environment:
Virtualbox instance ready to be used to develop Drupal applications - Drupal Devel Module a module which enables a set of handful functions to debug and print on screen custom and drupal variables; have a look at the documentation, which is full of information
- Devel Themer while developing a theme this module is extremely useful; again, look at the docs for a complete overview
- File logger is a module that allows developers to configure a log file from within Drupal and dump variables to it from within a running Drupal app
- How do I debug Drupal? a similar question posted on StackExchange Drupal Answer, with lot of resources for debugging Drupal and/or PHP applications.
After development you could use a tool like scp or Filezilla ( for FTP ) to upload your file to the server.
Happy coding! :)
精彩评论