Jump to content
mav_medved

PW3 include&bootstrap: undefined function wire()

Recommended Posts

Hi everyone!

Function wire() doesn't work in PW3 api after including pw's index.php

Trying to use it exactly the same I use it in pw2 api.
 

<?php
require_once('/path/to/pw/index.php');
$test = wire('pages')->find('parent_id=1019');

I'm getting an error: PHP Fatal error:  Call to undefined function wire()

Though https://processwire.com/api/include/ says I can use wire() function as before.

Btw, this one works:

$wire->pages->find('parent_id=1019');

But I want my old scripts work with wire() function in pw3.

Any ideas what could be wrong?

Share this post


Link to post
Share on other sites
29 minutes ago, mav_medved said:

<?php

Change this line to <?php namespace ProcessWire;

With v3.0, all global functions are now under ProcessWire namespace, so you need to either declare namespace at the top or prefix function calls (\ProcessWire\wire() for instance)

  • Like 4
  • Thanks 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...