dongyisa6254 2013-02-16 17:03
浏览 54
已采纳

使用php / silex“未找到类”

I set up a Silex-project local using a XAMPP on Mac. Everything works fine. Now I uploaded the files to my Amazon ec2 server and tried to run it. I always get the php errormessage:

"Fatal error: Class 'Silex\Application' not found in /opt/bitnami/apps/..."

I'm using Composer to handle the dependencies. The first lines of my file look like this:

<?php
require_once __DIR__.'/../vendor/autoload.php';

$app = new Silex\Application();
$app['debug'] = true;

Anyone has a clue how to solve that? Where could there be a problem?

Thanks a lot! Cheers

  • 写回答

1条回答 默认 最新

  • duanchun6148 2013-02-17 14:06
    关注

    As suspected, you are using some sort of git-based deployment process.

    Currently there is no tagged stable release of silex (EDIT: as of now, there is). As a result, composer will install it from source, resulting in the silex github repository being cloned into vendor/silex/silex. Since that folder is a git repo itself, those files cannot be added to your main repo. Which means that on your server the vendor/silex/silex directory simply will not exist.

    If you really want to, you can apply the fix of running composer install with the --prefer-dist flag, which will force to install silex from a zip archive, allowing the directory to be added to your git repo.

    But I would say that you should not be committing your vendors into version control. This is also covered by this entry in the composer FAQ:

    I suggest adding vendor to your .gitignore and running composer install as part of your CI and deployment process.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?