So, you need to create a custom extension with the following file structure (for example adding new action to checkout/cart/):
We need the following files to make it work:
1) registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Amasty_Checkout',
__DIR__
);
2) composer.json
{
"name": "amasty/checkout",
"description": "Amasty Test",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"amasty/base": "*"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
"Commercial"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Amasty\\Checkout\\": ""
}
}
}
3) module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Amasty_Checkout" schema_version="1.0.0" setup_version="1.0.0">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
4) routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="checkout">
<module name="Amasty_Checkout" />
</route>
</router>
</config>
5) Test.php (adding /test/ action)
<?php
namespace Amasty\Checkout\Controller\Cart;
class Test extends \Magento\Checkout\Controller\Cart\Add
{
public function execute()
{
die('asdasdasd');
}
}
And this is the result: