Essentially, your general plan has a lot of problems with it. First, since you are removing the .php, the rewrite has to be outside of location ~ .php$ since the URL won't end in .php until after it is rewritten. Second, your rewrite is backwards. You want the URL http://www.example.com/foo/ to run foo.php, so the rewrite would need to be
 rewrite ^(.+)/ $1.php; 
 But this means that EVERY directory on your website would need a matching .php file since you will no longer be able to use index.php automatically. Also, if nginx does not de-duplicate slashes before rewriting, if someone mistypes an address as http://www.example.com/foo// then it will execute /foo/.php.
 Finally, how many PHP files are you planning on creating? Do you really think serverfault has a 304162.php file for this question? (not that serverfaults' URL would match your rewrite since it doesn't end in /, nor do they use PHP I think)
 Normally, clean URLs work by declaring a specific location (for instance /questions/) then rewriting everything AFTER that URL to be run by a single script:
 rewrite ^/questions/(.*)$ /questions.php?path=$1 last; 
 You could also do something like
 rewrite ^/questions/([0-9]+)(/.*)?$ /questions.php?qid=$1&extra=$2 last; 
 So that URLs could be example.com/questions/1 example.com/questions/1/ example.com/questions/1/how-do-I-rewrite but example.com/questions/banana would be rejected for not having a numeric question id.
 Take a look at how people set up clean URLs for Drupal or Wordpress. Essentially, every request for a file that does not exist is rewritten as /index.php?q=$1, where index.php looks at the "q" variable to figure out what it is supposed to do.
   
foo.phpto/foo(you say you want .php replaced with "/" but your rewrite has the slash on the wrong side of $1), then PHP will try to execute/foowhich probably does not exist. Moving the slash to the end means PHP will try to executefoo/which still won't work.