Hi all, before submitting my question I wanna compliment with the Processwire dev team!
You guys not only have managed to create a crazy-simple framework in its core concepts but are empowering people like me to understand clean and pure PHP scripting!
Here's my question:
I'm having troubles to implement a simple initDb.sh file that sets up the entire page hierarchy and structure.
The code is:
#!/usr/bin/php
<?php
include("./index.php"); // bootstrap ProcessWire
...
function createMockUsers() {
$item = new ProcessWire\User();
$item->setOutputFormatting(false);
$item->name = $wire->sanitizer->pageName("newname");
$item->pass = "yo12345";
$item->email = $wire->sanitizer->email("example@processwire.com");
$item->addRole('guest');
$item->save();
}
...
createMockUsers();
The error is:
Error: Call to a member function pageName() on null
Additionally, is there a better way to initialize a Processwire structure rather than using an external script? Aand, is there a nicer syntax for instantiating new classes (not like " $item = new ProcessWire\User();")
Thank you guys for your support and the wonderful piece of software you made!