Call Controller function from webroot file in Cakephp 3

In our example we call AppController function from webroot file. you can call any controller function from webroot file.

To Call Controller function from webroot file in Cakephp create a new file on webroot and paste this code-

<?php
namespace App\Controller;
use App\Controller\AppController;
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
require_once(dirname(dirname(__FILE__)).DS.'config'.DS.'bootstrap.php');
require_once(dirname(dirname(__FILE__)).DS.'src'.DS.'Controller'.DS.'AppController.php');
$user = new AppController();
$responseofappfunction = $user->yourAppControllerfunctionName();
?>