Jump to content

Howto: debug PHP pages (templates, etc) most efficiently with what tools?


motionmindz
 Share

Recommended Posts

1. I dont see a good way to check/inspect if my Jquery libs are correctly linked as are my CSS sheets.

  • In Chrome, click 'inspect' element, then click the network tab inside the inspector, there you can see what is loaded.

2. I want to debug step by step the PHP code.

  • In your config.php put:
    $config->debug = true; // Under no circumstance should you leave this ON with a live site. 
  • echo out, var_dump variables, to see if they have the expected outcome.

3. Read or watch movies about PHP.

4. Be eager !

  • Like 3
Link to comment
Share on other sites

First build up more routine with using html, css and especially the api inside processwire, then start with php

5. go through the processwire website tutorials

6. follow the examples you find included on many free picture galleries.

7. With google and this forum you can find many code snippets and try them out in processwire.

Have a look here too:

http://processwire.com/talk/topic/4173-grouped-forum-posts-links-articles-tutorials-code-snippets/

Link to comment
Share on other sites

+1 re the other suggestions, especially config->debug. Check the bottom of this page where it says

Maintaining a separate development configuration file
 
You may optionally maintain a separate development configuration file at /site/config-dev.php. When present, ProcessWire will use this file rather than /site/config.php. This may be useful on your development and/or staging server and allows you to maintain the same /site/config.php file between staging and production server. As an example, your /site/config-dev.php file may have the database connection information specific to your development server, while your /site/config.php has the database connection information specific to your production server. This prevents the possibility of overwriting your production server's configuration file during migrations and mirrors. Of course, you will want to ensure that your config-dev.php file does not end up on your production server by adding it to the file exclusion list of whatever tool you are using to transfer files.

The advantage of this is that you can have your local setup verbose about errors and your live site not verbose (by setting the config->debug differently in the two files). If you are very new then you may want to come back to look at this later since it's just a nicety (but a very nicety I think :))

Another good thing that is sometimes appropriate is to build and test the HTML+CSS+jQ first (ignoring any PW) then gradually introduce PW so for example have PW replace a static TITLE tag with data generated from PW.

  • Like 1
Link to comment
Share on other sites

Thanks a lot! I have found the Inspector in Nightly also to help. And the config-dev php file is a very good way of testing out stuff. Cheers !

One question though: does PW indicate in some way you are working with a config-dev file and therefore working in a test environment with test config settings ?

  • Like 1
Link to comment
Share on other sites

One question though: does PW indicate in some way you are working with a config-dev file and therefore working in a test environment with test config settings ?

I don't think it does(?).

But you could easily do this yourself.

For example create a variable (for consistency declare it in config.php as well as config-dev.php) and test for it. So config.php:

$config->showConfigDevPresent = 'no'; 

and config-dev.php:

$config->showConfigDevPresent = 'yes'; 

Then in your code, for example at the top of every page, check to see if this var is true and if so then have a styled alerting top row (or similar visual cue) to highlight this site is running with config-dev.php present.

In fact I think I'll do that from now on! :D Thanks for asking the question!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...