Jump to content

PW 3 devns CLI not recognising pw classes


Can
 Share

Recommended Posts

Hola,

just tried to write a little php cli to create a bunch of pages.

Whole api works (at least $sanitizer and $pages)

but new Page() is failing.

first file where in bin folder, second test file next to pws index.php. permission is fine.

#!/Applications/MAMP/bin/php/php5.6.7/bin/php
<?php
include 'index.php';
var_dump(new Page());

producing "Error: Class 'Page' not found" 

Okay got it. Now I got a little loader script

#!/Applications/MAMP/bin/php/php5.6.7/bin/php
<?php 
require 'scraper.php';

and in scraper.php I'm starting like

<?php namespace ProcessWire;
include 'index.php';

now it's working :D

Is there another way?

It's everytime again fascinating how much faster and less resource hungry than running mass importer in the browser  :rolleyes:

Link to comment
Share on other sites

Of course both work -.-

I tried multiple times to add the namespace ProcessWire at the top without any luck..now it just works haha :D

Just for the record, both of snippets work for me. Thank you teppo! Making my first namespace experiences with pw devns..

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