Wolff has its own CLI application named Wolffie, which can help you to automate process, get information about the current Wolff project and more.
To use it just move with your favorite terminal to your Wolff project directory (like this cd /xampp/htdocs/wolff
) and then write the following command:
php wolffie
Followeb by one of the commands explained here.
Wolffie has the following general commands.
The list function will show you a list of all the elements available in the project like the controllers, views and more.
To call it just write ls
followed by the element.
Example:
php wolffie ls controllers
That will show you a list of all the controllers.
The function can be called followed by one of these commands:
controllers
: All the controllersviews
: Available views (php and html)extensions
: Available extensionslanguages
: Available languagesroutes
: Declared routesblocked
: Blocked routesredirects
: Route redirectionspublic
: Files in the public foldercache
: Files in the cache folderip
: IPs in the maintenance mode white listconfig
: Config constants defined in config.phpYou can create multiple elements in a fast way using the mk
function.
Creating a new controller:
php wolffie mk controller homepage
That will create a homepage.php file inside the app/controller folder with the following code inside:
<?php
namespace Controller;
class homepage extends \Core\Controller {
public function index() {
//Code
}
}
If you specify a path like this:
php wolffie mk controller sub/homepage
And the sub folder doesn't exist, it will be created automatically.
Creating a new view:
php wolffie mk view homepage
That will create a homepage.php file inside the app/view folder with the following code inside:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>homepage</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<script src='main.js'></script>
</head>
<body>
</body>
</html>
If you specify a path like this:
php wolffie mk view sub/homepage
And the sub folder doesn't exist, it will be created automatically.
Creating a new extension:
php wolffie mk extension homepage
After running the previous command, you will be asked to enter the extension name, description, version and author.
That will create a homepage.php file inside the extension folder with the following code inside:
<?php
namespace Extension;
class {classname}
{
public $desc = array(
'name' => '{name}',
'description' => '{description}',
'version' => '{version}',
'author' => '{author}'
);
public function index() {
//Code
}
}
The text inside brackets will be obviously replaced with the data you introduced.
Creating a new page:
php wolffie mk page homepage
That will create a controller and view for the homepage automatically.
Creating a new language:
php wolffie mk language spanish
That will create the spanish folder inside the app/language folder.
Creating a route
php wolffie mk route page homepage
The first parameter after route is the desired route, the second is the controller which will be loaded.
That will add the following code to the Routes.php file inside the system folder:
Route::add("page", function() {
$this->load->controller("homepage");
});
Creating a block for a route
php wolffie mk block homepage
That will add the following code to the Routes.php file inside the system folder:
Route::block("homepage");
The first parameter after route is the desired route to block.
Creating a redirection for a route
php wolffie mk redirect original homepage
That will add the following code to the Routes.php file inside the system folder:
Route::redirect("original", "homepage");
The first parameter after route is the origin route, the second is the destiny.
You can pass an optional third parameter which will be the HTTP response code like this:
php wolffie mk redirect original homepage 200
Adding an IP to the maintenance mode white list:
php wolffie mk ip 192.168.0.1
You can delete elements using the rm
function followed by the element type and name.
Example, deleting the homepage controller
php wolffie rm controller homepage
That will delete the homepage.php file in the app/controller folder.
The same can be applied to a language
, ip
, cache
or extension
.
When deleting a view, the file extension must be specified, since a view can be a php, html or phtml file.
If no name is specified when running a rm cache
command, all the cache files will be deleted.
Example deleting the homepage view
php wolffie rm view homepage.html
This will export the indicated query in a .csv file.
Example:
php wolffie export "SELECT * FROM tablename"
That will export all the content of the table named tablename in a .csv file and will put it inside the cli folder.
You can change the constants defined in the config.php
file using the set function.
Easy example changing the language to spanish:
php wolffie set language 'spanish'
That will replace the line where the language is defined with this:
'language' => 'spanish',
Keep in mind that when calling the set function, the constant name doesn't need to be uppercase.
The help function will give you information about the available functions in Wolffie, it's something like this wiki page.
php wolffie help
You can write help followed by one of the general commands explained here to read information about that command.
Example:
php wolffie help ls
Calling the version
function, will give you the current Wolff version.
php wolffie version