CakePHP 3.0 not running on other machines

主宰稳场 提交于 2020-01-17 06:12:07

问题


I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines.

If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer, and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:

Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229

Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229

I've copied the whole project to this server to test.

I told you this because I thought it has something to do with my problem. The point is that I have to run this on a machine that is not mine, and I can't install composer on it. The /public_html/vendor/cakephp/cakephp/src/I18n/ has files related to internationalization and localization, but my project will never be translated, so a workaround to make the project ignore those files would be enough to solve my problem.

The following code is an excerpt from the (...)/I18n/I18n.php that might be relevant:

<?php
namespace Cake\I18n;

use Aura\Intl\FormatterLocator;
use Aura\Intl\PackageLocator;
use Aura\Intl\TranslatorFactory;
use Cake\I18n\Formatter\IcuFormatter;
use Cake\I18n\Formatter\SprintfFormatter;
use Locale;

class I18n {

    // lots of code here

    public static function defaultLocale() {
        if (static::$_defaultLocale === null) {
            static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
            // the line above is the Line 229
        }
        return static::$_defaultLocale;
    }

    // many code here too
}

I've checked that another file also tries to access this Locale class, but I don't know if there are other files trying to access it as well. Many files from everywhere inside the project tries to access methods from I18n.php. I need it running but I can't figure out how to make it run.

Any help will be greatly appreciated.


回答1:


As I just found out, prior to CakePHP 3.0, the installation must be done by composer, as stated in the 3.0 migration guide:

CakePHP should be installed with Composer

Since CakePHP can no longer easily be installed via PEAR, or in a shared
directory, those options are no longer supported. Instead you should use
Composer to install CakePHP into your application.

So it won't run on regular free web hosting services.



来源:https://stackoverflow.com/questions/27493761/cakephp-3-0-not-running-on-other-machines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!