# autoload helper file codeigniter 4

```
<?php
// BaseController.php
namespace App\Controllers;
use CodeIgniter\Controller;
class BaseController extends Controller {
  protected $helpers = ['common'];
  public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
    parent::initController($request, $response, $logger);
  }
}
```

```
<?php
BaseController.php
function public_url($url = '') {
  return base_url('public/' . $url);
}
```

```
<?php  
	// layout.php
	echo '<pre>';
		echo public_url('abc');
	echo '</pre>';
?>
```

![](https://2490666754-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LerNLj-aJvvv8EP6rXs%2F-M6nWl5mCrM33sAcoJgB%2F-M6nXdbAmeabp7Uoc_6I%2FScreenshot_1.png?alt=media\&token=43381a57-3e31-4844-9fe3-acf5e0c71150)

![](https://2490666754-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LerNLj-aJvvv8EP6rXs%2F-M6nWl5mCrM33sAcoJgB%2F-M6nXgM2LZGpS0j4phlM%2FScreenshot_2.png?alt=media\&token=1be2a112-dcc7-43e6-ba01-d95b9b0cd538)

![](https://2490666754-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LerNLj-aJvvv8EP6rXs%2F-M6nWl5mCrM33sAcoJgB%2F-M6nXiY7l6vvc5QiTtS2%2FScreenshot_3.png?alt=media\&token=b7600666-5034-4479-9f0d-dafc5f7b893a)
