CakePHP 3.0不能在其他机器上运行 [英] CakePHP 3.0 not running on other machines

查看:293
本文介绍了CakePHP 3.0不能在其他机器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在机器上开发了一个小项目,使用CakePHP 3.0,我需要它在另一台机器上运行。

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.

如果我运行 composer 来安装CakePHP 3.0 ,然后我复制我的东西覆盖它,项目工作。我试过这个在两台机器,到目前为止没有问题。如果我不运行 composer ,只是将东西复制到目标机器,它给我以下错误。我在3台机器上试过这个,每台机器给我这个:

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.

我告诉过你这是因为我认为它与我的问题有关系。关键是我必须在不是我的机器上运行它,并且我不能在其上安装作曲家。 / public_html / vendor / cakephp / cakephp / src / I18n / 有与国际化和本地化相关的文件,但我的项目将永远不会被翻译,所以一个解决方案使项目忽略这些文件将足以解决我的问题。

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.

以下代码是从(...)/ I18n / I18n中摘录的。可能相关的

<?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
}

我已经检查另一个文件也试图访问这个 Locale 类,但我不知道是否有其他文件尝试访问它。项目中任何地方的许多文件尝试访问 I18n.php 中的方法。我需要它运行,但我不知道如何让它运行。

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.

任何帮助将非常感激。

推荐答案

正如我刚刚发现的,在 CakePHP 3.0 之前,安装必须通过作者,如中所述3.0迁移指南

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.

这篇关于CakePHP 3.0不能在其他机器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆