hellomoto Posted March 25 Share Posted March 25 When I include index.php and run the script via command line `php bootstrap.php` this error is returned: PHP Warning: Cannot modify header information - headers already sent by (output started at /pw/bootstrap/index.php:5) in /pw/index.php on line 41 404 page not found (no site configuration or install.php available) I've tried moving the script around also and it's the same if external... <?php namespace ProcessWire; if (!class_exists('ProcessWire\Templates')) { // $pw_dir = dirname(dirname(__FILE__), 2); echo $pw_dir; $boot = "../pw/index.php"; $boot = realpath($boot); echo $boot; require_once $boot;// $pw_dir.'/index.php'; echo 'booted'; exit; } (so as to not include if ran from within PW instance, also tried with no condition) Link to comment Share on other sites More sharing options...
gornycreative Posted March 25 Share Posted March 25 This thread and tool may help you out: Link to comment Share on other sites More sharing options...
bernhard Posted March 25 Share Posted March 25 @hellomoto you have to install ProcessWire and make sure it works before you can load it as a boostrapped app. Link to comment Share on other sites More sharing options...
hellomoto Posted March 26 Author Share Posted March 26 Thanks it is installed? Link to comment Share on other sites More sharing options...
da² Posted March 27 Share Posted March 27 On 3/25/2024 at 4:22 PM, hellomoto said: Cannot modify header information - headers already sent by (output started at /pw/bootstrap/index.php:5) in /pw/index.php on line 41 @hellomoto It's a common error. You are outputting data before the headers, but headers must be the first thing to output. Headers are sent by ProcessWire, but you echo something before to include PW: $boot = realpath($boot); echo $boot; // DO NOT echo something... require_once $boot;// $pw_dir.'/index.php'; // ...BEFORE PW sent headers. Also why do you use this code and not a simple include at start of file? include __DIR__ . "/../index.php"; Link to comment Share on other sites More sharing options...
hellomoto Posted March 27 Author Share Posted March 27 Wow I missed that thank you. The conditional inclusion is so as to not repeat if running from within PW already, only require if ran from outside PW. var_dump(class_exists('ProcessWire')); returns false from within it so that's why it's \Templates... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now