• I’m having some trouble including WordPress from outside itself via command line.

    When visiting hello.php in the browser, it works just fine; however, when executed via command line, php5 /var/project1/hello.php, nothing happens.

    hello.php contains only the following code:

    ` <?php
    require(‘/var/project2/wp-load.php’);
    echo “hello world”;
    ?>`

    When I delete require('var/project2/wp-load.php'); from the code, and execute via command line, it correctly displays hello world.

    I checked permissions, which are fine (unless I’m mistaken). There aren’t any errors in nginx or php5-fpm. Requiring wp-blog-header.php instead of wp-load.php has the same effect.

    I’m completely stumped as to how to make php5 /var/project1/hello.php correctly execute.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, it could be that PHP could not resolve the directory for wp-load.php with respect to hello.php. Perhaps you can try the following:

    require(__DIR__ . '/../project2/wp-load.php');
    echo "hello world";

    This is based on the assumption that both wp-load.php and hello.php are in the /var directory, but the former is in project2 and the latter is in project1.

    Jon (Kenshino)

    (@kenshino)

    Lord Jon

    Or – this may not be popular.

    If you’re looking to exchange data with WordPress – try using the REST API

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress Outside of WordPress Not Executing’ is closed to new replies.