Jump to content

Include and bootstrap with PW 3


suntrop
 Share

Recommended Posts

Has anything changed from v. 2.5 to v. 3 when I include/bootstrap PW from another file?

The last time I used this in PW 2.5.2 my code worked, but now it doesn't. Some of the API vars are not present and none of the classes are found.

require '../index.php';
echo $wire->pages->get("/")->name;  // works

echo wire('pages')->get("/")->name;  // doesn't work

$u = new User();  // Error: Class 'User' not found 

Couldn't find infos if there are changes on how to bootstrap PW in version 3

Link to comment
Share on other sites

I think it has to do with namespace.

Have you tried to prefix your file with

<?php namespace ProcessWire;

or maybe it also works if you add

<?php
use ProcessWire;

----

Or you can call it

$u = new ProcessWire\User();
Edited by horst
  • 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...