MrAnchovy / Kohana_Smarty3

Integration of Smarty v3 with the Kohana PHP Framework
25 stars 13 forks source link

The requested view index.tpl could not be found #20

Closed Lithl closed 10 years ago

Lithl commented 10 years ago

On my localhost (Windows), I have this module working fine. On my server (Debian), Kohana can't find my template files. (Both server and local have the same file versions, and server has correct permissions on all files.) This applies to all of my controllers which display a view (with the appropriate template file substituted, of course).

Kohana is dying at SYSPATH/classes/Kohana/View.php when Kohana::find_file('views', $file) fails to find the template. A cursory look over find_file suggested to me that it may be trying to look for index.tpl.php instead of index.tpl. I added echo $path.'<br>'; to find_file to confirm my suspicions, and I was correct: on my localhost, one of the lines output is views\index.tpl, while on my server, I see views/index.tpl.php.

However, I discovered another oddity. Here is the full list of paths Kohana is looking for on each of my server and my local machine:

LOCAL:                                             SERVER:
classes\I18n.php                                   classes/I18n.php
classes\Kohana\I18n.php                            classes/Kohana/I18n.php
classes\HTTP.php                                   classes/HTTP.php
classes\Kohana\HTTP.php                            classes/Kohana/HTTP.php
classes\Kohana\Exception.php                       classes/Kohana/Exception.php
classes\Kohana\Kohana\Exception.php                classes/Kohana/Kohana/Exception.php
classes\Log.php                                    classes/Log.php
classes\Kohana\Log.php                             classes/Kohana/Log.php
classes\Config.php                                 classes/Config.php
classes\Kohana\Config.php                          classes/Kohana/Config.php
classes\Log\File.php                               classes/Log/File.php
classes\Kohana\Log\File.php                        classes/Kohana/Log/File.php
classes\Log\Writer.php                             classes/Log/Writer.php
classes\Kohana\Log\Writer.php                      classes/Kohana/Log/Writer.php
classes\Config\File.php                            classes/Config/File.php
classes\Kohana\Config\File.php                     classes/Kohana/Config/File.php
classes\Kohana\Config\File\Reader.php              classes/Kohana/Config/File/Reader.php
classes\Kohana\Config\Reader.php                   classes/Kohana/Config/Reader.php
classes\Kohana\Config\Source.php                   classes/Kohana/Config/Source.php
classes\Route.php                                  classes/Route.php
classes\Kohana\Route.php                           classes/Kohana/Route.php
classes\Cookie.php                                 classes/Cookie.php
classes\Kohana\Cookie.php                          classes/Kohana/Cookie.php
classes\Session.php                                classes/Session.php
classes\Kohana\Session.php                         classes/Kohana/Session.php
classes\Request.php                                classes/Request.php
classes\Kohana\Request.php                         classes/Kohana/Request.php
classes\HTTP\Request.php                           classes/HTTP/Request.php
classes\Kohana\HTTP\Request.php                    classes/Kohana/HTTP/Request.php
classes\HTTP\Message.php                           classes/HTTP/Message.php
classes\Kohana\HTTP\Message.php                    classes/Kohana/HTTP/Message.php
classes\HTTP\Header.php                            classes/HTTP/Header.php
classes\Kohana\HTTP\Header.php                     classes/Kohana/HTTP\Header.php
classes\Request\Client\Internal.php                classes/Request/Client/Internal.php
classes\Kohana\Request\Client\Internal.php         classes/Kohana/Request/Client/Internal.php
classes\Request\Client.php                         classes/Request/Client.php
classes\Kohana\Request\Client.php                  classes/Kohana/Request/Client.php
classes\Arr.php                                    classes/Arr.php
classes\Kohana\Arr.php                             classes/Kohana/Arr.php
classes\Response.php                               classes/Response.php
classes\Kohana\Response.php                        classes/Kohana/Response.php
classes\HTTP\Response.php                          classes/HTTP/Response.php
classes\Kohana\HTTP\Response.php                   classes/Kohana/HTTP/Response.php
classes\Profiler.php                               classes/Profiler.php
classes\Kohana\Profiler.php                        classes/Kohana/Profiler.php
classes\Controller\Home.php                        classes/Controller/Home.php
classes\Controller\HFTemplate.php                  classes/Controller/HFTemplate.php
classes\Controller\Template.php                    classes/Controller/Template.php
classes\Kohana\Controller\Template.php             classes/Kohana/Controller/Template.php
classes\Controller.php                             classes/Controller.php
classes\Kohana\Controller.php                      classes/Kohana/Controller.php
classes\View.php                                   classes/View.php
classes\Kohana\View.php                            classes/Kohana/View.php
classes\Smarty\View.php
config\smarty.php
classes\Config\Group.php
classes\Kohana\Config\Group.php
vendor\smarty/libs/Smarty.class.php
classes\URL.php
classes\Kohana\URL.php
classes\Smarty\Helper.php
classes\Kohana\Smarty\Helper.php
views\index.tpl                                    views/index.tpl.php
classes\Auth.php
classes\Kohana\Auth.php
config\auth.php
classes\Auth\ORM.php
classes\Kohana\Auth\ORM.php
config\session.php
classes\Session\Database.php
classes\Kohana\Session\Database.php
classes\Database.php
classes\Kohana\Database.php
config\database.php
classes\Database\PDO.php
classes\Kohana\Database\PDO.php
classes\DB.php
classes\Kohana\DB.php
classes\Database\Query\Builder\Select.php
classes\Kohana\Database\Query\Builder\Select.php
classes\Database\Query\Builder\Where.php
classes\Kohana\Database\Query\Builder\Where.php
classes\Database\Query\Builder.php
classes\Kohana\Database\Query\Builder.php
classes\Database\Query.php
classes\Kohana\Database\Query.php
classes\Database\Result\Cached.php
classes\Kohana\Database\Result\Cached.php
classes\Database\Result.php
classes\Kohana\Database\Result.php
classes\ORM.php
classes\Kohana\ORM.php
classes\Model.php
classes\Kohana\Model.php
classes\Model\User.php
classes\Model\Auth\User.php
classes\Inflector.php
classes\Kohana\Inflector.php
config\inflector.php
classes\UTF8.php
classes\Kohana\UTF8.php
classes\Model\Role.php
classes\Model\Auth\Role.php
                                                   classes/View/Exception.php
                                                   classes/Kohana/View/Exception.php
                                                   classes/Debug.php
                                                   classes/Kohana/Debug.php
                                                   classes/Date.php
                                                   classes/Kohana/Date.php
                                                   views/kohana/error.php
                                                   classes/Text.php
                                                   classes/Kohana/Text.php
(page content)                                     (exception page content)
classes\Database\Query\Builder\Update.php
classes\Kohana\Database\Query\Builder\Update.php

Notice the large gap where Kohana should be looking for Smarty module classes. Any ideas?

mrbrownisintown commented 10 years ago

Sounds like the module isn't enabled in the bootstrap?

Lithl commented 10 years ago

Unfortunately, it is (I did double-check). My server hosts my SVN respository in addition to my website, and I have a post-commit hook to update my staging site whenever there's a new revision. Thus, assuming I don't have uncommitted changes, my staging site and my local copy are always identical codebases.

My post-commit hook is, essentially:

# Always update staging
svn update /var/www/staging --accept theirs-full

# Check if the commit was a tagged version
SVNLOOK=$(svnlook history -r $REV $REPOS /tags | grep $REV)
if [ -n $SVNLOOK ]; then
    # Get the tag name
    TAG=$(svn ls file://$REPOS@$REV ^/tags | tail -1)

    # Move production to the new version
    svn switch file://$REPOS/tags/$TAG /var/www/production
fi

There is no difference between /var/www/staging/application/bootstrap.php and E:\Projects\cmdr-class\application\bootstrap.php; both have Smarty enabled as a module, but only one of the two works.

MrAnchovy commented 10 years ago

Kohana is not finding the Kohana-Smarty module at all. I can only think of the following:

Lithl commented 10 years ago

In application/bootstrap.php:

Kohana::modules(array(
    'auth'     => MODPATH.'auth',
    'database' => MODPATH.'database',
    'orm'      => MODPATH.'orm',
    'smarty'   => MODPATH.'smarty'
));

Added:

echo MODPATH.'smarty';

Result:

/var/www/staging/modules/smarty

(This exists, and is where my Smarty module is located)

/var/www and all files and directories under it have drwxr-xr-x or -rw-r--r-- permissions, owned by user www-data and group root. Apache/PHP runs my scripts as www-data.

mrbrownisintown commented 10 years ago

Weird stuff.

Only thing I can think about is, since you're talking about staging, your svn hook says move to production. Could that be something?

svn switch file://$REPOS/tags/$TAG /var/www/production

Lithl commented 10 years ago

When I commit a revision, staging (which is a svn working directory) updates to the head revision of the trunk (the one just committed). when I tag a revision, production (also a svn working directory) switches from whatever it's currently pointing to, to the tagged version.

MrAnchovy commented 10 years ago

Do the other modules you have enabled work? Can you use an ordinary PHP page template in your controller to try things out?

I assume you are using the master branch, I have just noticed a problem there with duplicate directory names due to some combination of Windows and Linux machines generating and applying pull requests and running tests. I will fix this.

Lithl commented 10 years ago

Just tested my three controllers that I use for AJAX requests; one requests data from a third party via curl, and the other two query my database using the orm module (and thus indirectly using the database module). All function correctly, although I don't currently have a controller without a view with which to test auth.

On the flip side, testing those three controllers made me realize that I hadn't actually installed curl on my server, let me find a bug in my SQL connection configuration for PHP, and let me find a logic error in one of my queries. :)

MrAnchovy commented 10 years ago

I think the problem is caused by case sensitive file names (e.g. View.php and view.php). Try deleting view.php and the classes/controller, classes/kohana and classes/smarty directories on the linux box for a quick fix.

I need to revisit the pull request converting to Kohana 3.3 compatibility: it may take 48 hours to test properly and sort GitHub.

seyfer commented 10 years ago

@MrAnchovy , if you will accept pull to converting to Kohana 3.3 compatibility, please leave some branch for 3.2 users, like 3.2/master, with lowercase file names.

Lithl commented 10 years ago

@MrAnchovy Huzzah! I capitalized the following filenames, and now it works:

Only the two view.php files and the two helper.php files needed changing. The changes do not negatively affect my Windows local copy.

MrAnchovy commented 10 years ago

@Lithl thanks, I will update GitHub later. @seyfer the V1 branch will remain as the version to use for Kohana 3.0-3.2. I will put a link to this in the README in master.

seyfer commented 10 years ago

@MrAnchovy , you can accept this pull https://github.com/MrAnchovy/Kohana_Smarty3/pull/19 but please, make smarty via composer in https://github.com/MrAnchovy/Kohana_Smarty3/tree/V1 branch too. thank you.

MrAnchovy commented 10 years ago

I've just tagged 2.0.1 which resolves this issue. I have also added composer.json to the master (Kohana 3.3) branch but not yet to the 1.x branch, I'll follow this up in a separate issue.