Jump to content

Do my web app pages need to be inside the process wire folder to access the API?


dweeda
 Share

Recommended Posts

I was able to include Processwire using

use ProcessWire\ProcessWire;
// specify installation root 
$wire = new ProcessWire('../');

To answer your question, I dont think it's required. Here's the relevant bit from the core.

// wire/core/Processwire.php
	/**
	 * Create a new ProcessWire instance
	 * 
	 * ~~~~~
	 * // A. Current directory assumed to be root of installation
	 * $wire = new ProcessWire(); 
	 * 
	 * // B: Specify a Config object as returned by ProcessWire::buildConfig()
	 * $wire = new ProcessWire($config); 
	 * 
	 * // C: Specify where installation root is
	 * $wire = new ProcessWire('/server/path/');
	 * 
	 * // D: Specify installation root path and URL
	 * $wire = new ProcessWire('/server/path/', '/url/');
	 * 
	 * // E: Specify installation root path, scheme, hostname, URL
	 * $wire = new ProcessWire('/server/path/', 'https://hostname/url/'); 
	 * ~~~~~
	 * 
	 * @param Config|string|null $config May be any of the following: 
	 *  - A Config object as returned from ProcessWire::buildConfig(). 
	 *  - A string path to PW installation.
	 *  - You may optionally omit this argument if current dir is root of PW installation. 
	 * @param string $rootURL URL or scheme+host to installation. 
	 *  - This is only used if $config is omitted or a path string.
	 *  - May also include scheme & hostname, i.e. "http://hostname.com/url" to force use of scheme+host.
	 *  - If omitted, it is determined automatically. 
	 * @throws WireException if given invalid arguments
 	 *
	 */ 
public function __construct($config = null, $rootURL = '/') { ... }
Link to comment
Share on other sites

3 hours ago, diogo said:

@dweeda here is all the info you need https://processwire.com/api/include/

@abdus the info above is the official way to do this.

Any disadvantages to the way I do it? From what I understand, with v3.0 and Composer support, autoloading and use statements replaced (or is just as effective as) the older/traditional include "index.php"  way of including Processwire.

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

×
×
  • Create New...