Jump to content

Create page from command line script failed


simon
 Share

Recommended Posts

Hi guys,

I treid to create a new page with a command line script. Unfortunately the Page class was not fount.

Fatal error: Class 'Page' not found in *.php on line 6

How can I easily fix this?

 

<?php
include("../../index.php"); 	// include processwire bootstrap
$page = new Page();				// create new page from api
...
?>

 

 

 

 

 

Link to comment
Share on other sites

Sounds like a namespace issue because bootstrapped files don't get run through the file compiler you will either need to add namespace ProcessWire; to the top of the file, or do:

$page = new \ProcessWire\Page();

to reference the ProcessWire namespace

  • Like 2
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...