Can Posted February 23, 2016 Share Posted February 23, 2016 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 Is there another way? It's everytime again fascinating how much faster and less resource hungry than running mass importer in the browser Link to comment Share on other sites More sharing options...
teppo Posted February 23, 2016 Share Posted February 23, 2016 As far as I can tell, there are two solutions to your issue: <?php namespace ProcessWire; require 'index.php'; var_dump(new Page()); ... or: <?php require 'index.php'; var_dump(new \ProcessWire\Page()); 3 Link to comment Share on other sites More sharing options...
Can Posted February 23, 2016 Author Share Posted February 23, 2016 Of course both work -.- I tried multiple times to add the namespace ProcessWire at the top without any luck..now it just works haha Just for the record, both of snippets work for me. Thank you teppo! Making my first namespace experiences with pw devns.. 1 Link to comment Share on other sites More sharing options...
teppo Posted February 23, 2016 Share Posted February 23, 2016 Glad I could help Link to comment Share on other sites More sharing options...
Can Posted February 23, 2016 Author Share Posted February 23, 2016 blazingly fast! Thank you! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now