Error with index.php base

here’s the issue. http ://localhost/ loads the site. works perfectly. i have an image there using the img tag in HTML. it loads. then i click “home” or “about” and suddenly it changes to “alternate text” because it can’t find it.

basically: http ://localhost/ works with everything loading. http ://localhost/site/index (the same exact page) does not load correctly. the CSS code and all are still there. information and everything from the view. but the image isn’t found and instead displays the broken image link. not quite sure what’s up.

data! so, img link in question <p><img src="includes/websitebutterfly.jpg" alt="альтернативный текст"></p> (its in a folder i made called includes. and it loads normally until any link on the side is followed… so, its in the right place. )

so… that means its a config error.

configs! in frontend/config/main.php


<?php

$params = array_merge(

    require(__DIR__ . '/../../common/config/params.php'),

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

    require(__DIR__ . '/params.php'),

    require(__DIR__ . '/params-local.php')

);


return [

    'id' => 'app-practical-frontend',

    'name' => 'My Company',

    'basePath' => dirname(__DIR__),

    'bootstrap' => ['log'],

    'controllerNamespace' => 'frontend\controllers',

    'components' => [    

        'user' => [

            'identityClass' => 'common\models\User',

            'enableAutoLogin' => true,

        ],

        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

                [

                    'class' => 'yii\log\FileTarget',

                    'levels' => ['error', 'warning'],

                ],

            ],

        ],

        'errorHandler' => [

            'errorAction' => 'site/error',

        ],     

    ],

    'params' => $params,

];

common/config/main.php


<?php

return [

    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',

    'components' => [

        'cache' => [

            'class' => 'yii\caching\FileCache',

        ],

	'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

        ]

    ],

];



other thing to note: debug tool doesn’t load at all… even when loading localhost straight up and everything else loads.

Hi,

So you are using advanced temaplte?

1) Regarding the Debug Toolbar:

Is your app initialized in development mode?

Described unter "Preparing application"

2) Regarding your image issue

Where exactly have you created your "includes" directory?

Under myproject/frontend/web/ ?

If yes, have you already tried to use the absolute path to your picture?

For example like this:




<img src="http://localhost/myproject/frontend/web/includes/websitebutterfly.jpg">



If yes, what is the result?

Regards

hi. yes.

  1. debug is setup. just makes a blank white bar on the bottom with “Not Found (#404): Unable to find debug data tagged with ‘56000c8a80fff’.” in it.

  2. that worked. apparently so did changing src to src="/includes/websitebutterfly.jpg" (added a / to the begining)

i could definately go through and add / to the beginning of everything. but i’m unsure on how to fix the debug. also, by adding the / to it, that means its going back to the root to find it… meaning its not actually looking for things in that web folder. how would i change that?

thanks sooooo much for helping

reinitalized debug mode just because… still getting the error obviously with a different hash this time.

Not Found (#404): Unable to find debug data tagged with ‘560013e93d89e’.

i’m getting, for the debug bar, this code


<div id="yii-debug-toolbar" data-url="/debug/default/toolbar?tag=56035816f3022" style="display: block;" class="yii-debug-toolbar-bottom">Not Found (#404): Unable to find debug data tagged with '56035816f3022'.</div>

as the data-url says, there should be a debug folder in the webroot… there’s not.

do i need to generate it? is there something i’ve done wrong?

Hi,

Actually it should work.

Are you working on Windows or on Ubuntu?

Have you installed Yii with Composer or with Archive-File?

If you are not on windows - have you checked if all folders have the correct permissions?

When Yii can’t write the debug log files - it can’t open it. ;)

Regards

Ubuntu.

Composer.

not sure what the permissions are supposed to be. i chowned it to myself. then chmod’d everything to 755. then ran the ./init script and let it set the permissions it sets on its own.

which directory is that in? just chmod 777 -R it?

thanks again. you’ve really helped a bunch.

Hi!

I guess debug information is written in following locations on advanced template:




project/backend/runtime/

project/frontend/runtime/



Check if in these folders are other folders… for example "debug".

If no - I guess it is permission problem.

If yes: Maybe you have a config issue for example in:

  • Virtual Host configuration

  • URL Configuration

  • Some .htacces file

Question:

When you open localhost in browser - what exactly do you see?

Regards

Ok, so whenever i clone my project from git and set it up, it ALWAYS has an issue with not being able to create the sessions folder inside of that runtime folder… which is now making sense as to why debug hates me now. it had me manually make the sessions folder. what permissions should it be? again, i just kinda set everything to 755 as per usual and then ran init which apparently changed permissions on a few other files it needed. i’ll chmod -R 777 the runtime folder, if its safe to do so and hope nothing explodes.

I see my website as normal (which is in debug mode) so it has a white bar at the bottom… that’s blank with that error on it. everything else loads oddly, but apparently i just have to add the / to the beginning of all the paths of assets and it works fine. without the /, it can’t find them.

ok. so, that worked. 777’d both backend and frontend runtime folders. thanks sooooooo much…

backend still wanted me to manually create the sessions folder, but debug and everything else on backend works like a charm.

all issues solved. thanks so much. i’m new to yii. so, everything like that suddenly not working and/or functioning strangely was new to me.

Hey,

Regarding the Permissions I found this:

Regarding my localhost question:

I ask because I guess, aside from the permission problem,

there is something not correct with your virtual host config.

Usually you do no have to add a / at the beginning of everything.

You said you are using advanced template,

but do you see frontend or backend on localhost? ;)

Usually - without setting any virtualhost you see on localhost:

localhost/myproject/

localhost/myproject/frontend/

localhost/myproject/backend

…etc

Regards

EDIT:

Oh I just see you have solved your permission problem. :)

Glad I could help.

thanks for the input on that last part. i’ll mess with it. i just installed lamp-server^ from apt-get on development machine and vestaCP on production server. both of them were acting up. it was probably the htaccess if anything was wrong with the configs because they weren’t touched and worked earlier, however the new htaccess was the one that came with yii 2.0 and the old one was one i wrote myself.

backend works fine now as well. i’m actually using the yii2-practical-advanced not just yii2-advanced. basically, they put the frontend/web/ folder in the webroot, so its more “practical” and works litterally the same but no one would help me after explaining what it was. so, thank you for helping me anyway. and the backend is as normally, just /backend/. its pretty nice. makes me sad its not on their downloads page. its super useful. i wanted my website urls to be super SEO friendly. so, it does that. and its nice.

one last question. do you know where i can find any documentation on the console app in the yii advanced thing? i’m not too sure /what/ it is, much less how to use it. i know there’s a bunch of tutorials on everything else, but i’ve not seen ANYTHING on the console part of it. not even in yii1 which is what my former site ran on.

Hi,

Console applications are - like the name said - applications running on console. ;)

For example:

You could write own commands / apps running on console…

And execute them for example with cron.

… the "init" command of yii-advanced is a console app / command.

One practical example:

Lets say a user registers on your website, receives activation mail but does not click the "activation link".

You could write a console app and execute it with cron which does:

  1. Receive all unactivated users.

  2. Check registered date and send an "Please activate your account" reminder.

etc…

The Guide is always the best source:

http://www.yiiframework.com/doc-2.0/guide-tutorial-console.html

There are also wiki articles:

http://www.yiiframework.com/wiki/820/yii2-create-console-commands-inside-a-module-or-extension/

And you find many about yii2 console apps on google.

Regards