File created in "app/Controller/Commerce/Product/Detail.php";
<?php
namespace App\Controller\Commerce\Product;
use Butterfly\Framework\Controller\Action;
class Detail extends Action
{
public function indexAction() {
}
}
Command
Parameters:
Parameter Name
Description
Required
class
Class Name
Yes
Parameter Name
Description
Required
name
Function Name
Yes
Parameter Name
Description
Required
description
Description
No (Optional)
bin/butterfly make:command User user:login:update 'User login update'
File created in "app/Command/User.php";
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class User extends Command
{
public function configure()
{
$this->setName("user:login:update")->setDescription("User login update");
parent::configure();
}
public function execute(InputInterface $input, OutputInterface $output)
{
}
}
twig-filter
Parameters:
Parameter Name
Description
Required
name
Filter Name
Yes
bin/butterfly make:twig:filter test_filter
Filter created in "app/View/TwigFilter/TestFilter.php
<?php
namespace App\View\TwigFilter;
class TestFilter
{
public function filter($parameter)
{
return $parameter;
}
}
twig-function
Parameters:
Parameter Name
Description
Required
name
Function Name
Yes
bin/butterfly make:twig:function test_function
Filter created in "app/View/TwigFunction/TestFunction.php
<?php
namespace App\View\TwigFunction;
class TestFunction
{
public function execute($params)
{
return print_r($params, true);
}
}
Model
Parameters:
Parameter Name
Description
Required
model
Model Name
Yes
folder
Folder Name
No
bin/butterfly make:model Detail Commerce/Product
File created in "app/Model/Commerce/Product/Detail.php";
<?php
namespace App\Model\Commerce\Product;
use Butterfly\Library\Model;
class Detail extends Model
{
public $_name = "Detail";
}
Hook
Parameters:
Parameter Name
Description
Required
hook
Hook Name
Yes
bin/butterfly make:hook User
File created in "app/Hook/User.php";
<?php
namespace App\Hook;
use Butterfly\Library\Hook;
class User extends Hook
{
}
Event
Parameters:
Parameter Name
Description
Required
class
Class Name
Yes
Parameter Name
Description
Required
func
Function Name
Yes
bin/butterfly make:event User login
File created in "app/Event/User.php";
<?php
namespace App\Event;
use Butterfly\Library\Hook;
class User extends Hook
{
public function login()
{
}
}
Widget
Parameters:
Parameter Name
Description
Required
widget
Widget Name
Yes
folder
Folder Name
No
Without Folder
If you are creating a general widget, which you need it directly in app/Widget/, you can use command without a folder.
Example:
bin/butterfly make:widget Product
File successfully created in app/Widget/Product/Product.php
File successfully created in app/Widget/Product/Product.tpl
File successfully created in app/Widget/Product/parameters.yaml
Php file:
<?php
namespace App\Widget\Product;
class Product extends \Butterfly\Library\Widget
{
protected $_friendly_name = "Product";
public function init() {
return $this->render();
}
}
With Sub Folders
If you want to group your widgets, you can use second parameter to create your widget in a sub folder. Sub folder will be located in app/Widget/, you can use deeper folders.
File successfully created in app/Widget/General/Products/ProductDetail/ProductDetail.php
File successfully created in app/Widget/General/Products/ProductDetail/ProductDetail.tpl
File successfully created in app/Widget/General/Products/ProductDetail/parameters.yaml
Php file:
<?php
namespace App\Widget\General\Products\ProductDetail;
class ProductDetail extends \Butterfly\Library\Widget
{
protected $_friendly_name = "Product Detail";
public function init() {
return $this->render();
}
}
Content Widget
Parameters:
Parameter Name
Description
Required
widget
Widget Name
Yes
folder
Folder Name
No
Content Widget is a type of Widget which aims to display your contents. Content Widgets accepts Content Pool parameter to determine data that will be displayed.
Content Pools make it easy to make your display layer content agnostic. Which means that, you can change the data to be displayed without changing your code.
You can get more details from Content Pools Section.
Without Folder
If you are creating a general widget, which you need it directly in app/Widget/, you can use command without a folder.
Example:
bin/butterfly make:content-widget Product
File successfully created in app/Widget/Product/Product.php
File successfully created in app/Widget/Product/Product.tpl
File successfully created in app/Widget/Product/parameters.yaml
Php file:
<?php
namespace App\Widget\Product;
class Product extends \Butterfly\Framework\Widget\ContentPool
{
protected $_friendly_name = "Product";
protected $content_pools = ['content_pool_id'];
public function init() {
parent::init();
return $this->render();
}
}
If you want to group your widgets, you can use second parameter to create your widget in sub folder. Sub folder will be located in app/Widget/, you can use deeper folders.
File successfully created in app/Widget/General/Products/ProductDetail/ProductDetail.php
File successfully created in app/Widget/General/Products/ProductDetail/ProductDetail.tpl
File successfully created in app/Widget/General/Products/ProductDetail/parameters.yaml
Php file:
<?php
namespace App\Widget\General\Products\ProductDetail;
class ProductDetail extends \Butterfly\Framework\Widget\ContentPool
{
protected $_friendly_name = "Product Detail";
protected $content_pools = ['content_pool_id'];
public function init() {
parent::init();
return $this->render();
}
}