Problems hosting advanced (improved) template on shared host


I’ve been using the Advanced Improved Template ( to set up my application on my localhost. One of the main reasons I went with that as opposed to the standard advanced template structure was the fact that all of the non public files are stored in a _protected folder which we can put outside of the webroot.

I’ve uploaded all of the files (well I think I have but have to do it via FTP lol) - and have adjusted the index.php file to reflect the fact that I have the _protected folder outside of the web root (public_html)

defined('YII_DEBUG') or define('YII_DEBUG', false);

defined('YII_ENV') or define('YII_ENV', 'prod');

require(__DIR__ . '/../_protected/vendor/autoload.php');

require(__DIR__ . '/../_protected/vendor/yiisoft/yii2/Yii.php');

require(__DIR__ . '/../_protected/common/config/bootstrap.php');

require(__DIR__ . '/../_protected/frontend/config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(

    require(__DIR__ . '/../_protected/common/config/main.php'),

    require(__DIR__ . '/../_protected/common/config/main-local.php'),

    require(__DIR__ . '/../_protected/frontend/config/main.php'),

    require(__DIR__ . '/../_protected/frontend/config/main-local.php')


$application = new yii\web\Application($config);


I know the path to the protected folder is correct. I have also double checked the requirements file as recommended in the guide

When I visit the home page, I get a blank screen.

The index page fails at the first hurdle

require(__DIR__ . '/../_protected/vendor/autoload.php');

The autoload.php file contains this code

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit99f18e5c7af8fd3420ac067a3f9fe0fa::getLoader();

I don’t know what to do ! Any help much appreciated - hope solving this will help me move on!

Addition: the problem in the autoload.php file is the ::getLoader() call … but I’m struggling to see what the problem could be !

You need to contact the author of the template if you want help with it.

Many thanks for getting back. I’ve uploaded a fresh install of the template to the server - it’s fine. The problem relates to the Composer files - I’ll do some more digging.

You can’t use composer and then change the location of the ‘vendor’ directory after installation.

Not only is it unnecessary to upload all the vendor files by FTP, it also breaking in your case.

What you need to do is run composer install on the server after changing the path to _protected/vendor in the composer script.

Why are you changing the paths anyway?


Many thanks for getting back to me. Sorry - could you give me some more guidance - running composer install on a shared host (can I do this) and changing the path as you mention in the composer script. On my localhost the _protected folder is within the project folder, but on the server I’ve moved out of the webroot. Many thanks!

You simply need to move the folder out of the webroot on your development machine, run composer, and then upload it.

If you can’t use ssh on your host, that is all you need to do.

Because the paths need to stay the same.

Composer bakes the paths when it writes the autoloads. :)

Hi, many thanks for getting back to me - I was thinking about this, glad you’ve confirmed, will let you know how I get on!


I’ve done this - moved the vendor folder outside of the webroot on the localhost so it’s now on c:/wamp/vendor to match what I would have on the public server.

Now I have more problems eg

Invalid Parameter – yii\base\InvalidParamException

The file or directory to be published does not exist: C:\wamp\www\yii2-advanced-template-improved-testing\_protected/vendor\bower/jquery/dist

 in C:\wamp\vendor\yiisoft\yii2\web\AssetManager.php at line 407


    public function publish($path, $options = [])


        $path = Yii::getAlias($path);


        if (isset($this->_published[$path])) {

            return $this->_published[$path];



        if (!is_string($path) || ($src = realpath($path)) === false) {

            throw new InvalidParamException("The file or directory to be published does not exist: $path");



        if (is_file($src)) {

            return $this->_published[$path] = $this->publishFile($src);

        } else {

            return $this->_published[$path] = $this->publishDirectory($src, $options);






I have this on the index page - which is blank (the backend/admin is fine)

<!DOCTYPE html>

<html lang="en">


<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="csrf-param" content="_csrf">

    <meta name="csrf-token" content="TXUuZjdnLTMrMHwoXVNsAw9BAwtzOF1WJkN9Fg8UZgp7LXEhbhN.fA==">

    <title>Error (#1)</title>


<body id="">


	<div class="row">

	<div class="medium-12 columns">

I have changed the paths in the production environment - these are pointing to the _protected folder outside of the root eg /home/sites/ etc

The backend is working fine - the problem is with the front end

Any help much appreciated!


Sorted it now - might be an idea to provide a clearer explanation for people hosting on a shared host who want the (protected) vendor folder outside of the webroot due to Composer bakeing the paths when it writes the autoloads.?

Anyway - many thanks for you help - much appreciated

I agree that Composer adds a bit of extra complexity, but I think it’s worth it. :)