Skip to content

Commit 013bd44

Browse files
committed
Added module to create custom console cmd
0 parents  commit 013bd44

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

Console/Clearcustomcache.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
namespace Binstellar\Console\Console;
3+
4+
use Symfony\Component\Console\Command\Command;
5+
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
8+
class Clearcustomcache extends Command
9+
{
10+
protected function configure()
11+
{
12+
$this->setName('clear:custom-cache');
13+
$this->setDescription('This command is used to clear custom cache.');
14+
15+
parent::configure();
16+
}
17+
protected function execute(InputInterface $input, OutputInterface $output)
18+
{
19+
$output->writeln("Clear Custom Cache");
20+
}
21+
}

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Magento2 Create custom console commands
2+
3+
> Magento2 an open-source e-commerce platform written in PHP.
4+
5+
> Here in this extension we are going to learn how to create custom commands in Magento2 to perform some functionality
6+
7+
> In this extension we have created a custom command to clear custom cache as an example.
8+
9+
10+
## Installation Steps
11+
12+
##### Step 1 : Download the Zip file from Github & Unzip it
13+
##### Step 2 : Create a directory under app/code/Binstellar/Console
14+
##### Step 3 : Upload the files & folders from extracted package to app/code/Binstellar/Console
15+
##### Step 4 : Go to the Magento2 Root directory & run following commands
16+
17+
php bin/magento setup:upgrade
18+
19+
php bin/magento setup:di:compile
20+
21+
php bin/magento setup:static-content:deploy -f
22+
23+
php bin/magento cache:flush
24+
25+
26+
## Note : We have tested this option in Magento ver. 2.4.5-p1

etc/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
3+
<type name="Magento\Framework\Console\CommandList">
4+
<arguments>
5+
<argument name="commands" xsi:type="array">
6+
<item name="clearcustomcache" xsi:type="object">Binstellar\Console\Console\Clearcustomcache</item>
7+
</argument>
8+
</arguments>
9+
</type>
10+
</config>

etc/module.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3+
<module name="Binstellar_Console" setup_version="1.0.0">
4+
</module>
5+
</config>

registration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
\Magento\Framework\Component\ComponentRegistrar::register(
3+
\Magento\Framework\Component\ComponentRegistrar::MODULE,
4+
'Binstellar_Console',
5+
__DIR__
6+
);

0 commit comments

Comments
 (0)