duanpiangeng8958 2013-07-19 02:50
浏览 45
已采纳

Cakephp 2.3.8无法在linux服务器上运行,但在我的macbookpro上运行oK

I develop some website on my MacBook Pro.use Cakephp 2.3.8. it work so good. but,I up the code to the linux server(on hostmonster.com). it had some bug.

environment for Mac: osx 10.8.4 PHP 5.3.15 with Suhosin-Patch (cli)

environment for Server: linux 2.6.32 PHP 5.3.26 (cgi-fcgi)

and the code is the same.

1、Error: Call to a member function find() on a non-object

controller:
 $kinds = $this->Nailcolor->Kind->find('list'); //it not work on server,but on my mac is ok.

model:
class nailcolor extends AppModel {
public $validate = array( ... )

public $belongsTo = array(
    'Kind' => array(
        'className' => 'Kind',
        'foreignKey' => 'kind_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

}

2、 debug($this->Nailcolor->find('first', $options));

result on mac

array(
    'Nailcolor' => array(
        'id' => '1',
        'kind_id' => '2',
        'name' => 'aaaa',
        'color' => 'aaaaa',
        'naila' => 'aaaa',
        'nailb' => 'aaaaa',
        'nailc' => 'ccc',
        'naild' => 'ccc',
        'naile' => 'ccc',
        'nailm' => 'aqaa',
        'description' => '',
        'created' => '2013-07-16 15:16:56',
        'modified' => '2013-07-16 15:16:56'
    ),
    'Kind' => array(    /*if run on server,not had "kind". */
        'id' => '2',
        'name' => 'kkkk',
        'description' => '',
        'created' => '2013-07-16 15:15:44',
        'modified' => '2013-07-16 15:15:44'
    )
)

result on server:

array(
    'Nailcolor' => array(
        'id' => '3',
        'kind_id' => '4',
        'name' => 'aaaa',
        'color' => '0203',
        'naila' => 'aaa',
        'nailb' => 'aaa',
        'nailc' => 'aaaaa',
        'naild' => 'aaaaaaa',
        'naile' => 'aaaaaa',
        'nailm' => 'aaaaaaaaa',
        'description' => '',
        'created' => '2013-07-18 02:51:29',
        'modified' => '2013-07-18 02:51:29'
    )
)

so on the view.ctp on the server is don't work.

<?php echo $this->Html->link($nailcolor['Kind']['name'], array('controller' => 'kinds', 'action' => 'view', $nailcolor['Kind']['id'])); ?>

why????how can I set the php.ini or cakephp settings???? I want the same result on my mac and on my server.

the code on the upside is generate by "cake bake" on my mac. and I cannot run the "cake bake" on the server.

  • 写回答

2条回答 默认 最新

  • dongpingwu8378 2013-07-19 08:29
    关注

    Your model file is the wrong case

    From the book:

    CakePHP will dynamically create a model object for you if it cannot find a corresponding file in /app/Model. This also means that if your model file isn’t named correctly (i.e. ingredient.php or Ingredients.php) CakePHP will use an instance of AppModel rather than your missing (from CakePHP’s perspective) model file.

    It should be named Nailcolor.php - from the question I guess it's called nailcolor.php, Mac OSX is a case insensitive (by default) and hence can find the file whereas linux (which is case sensitive) cannot. There's more about CakePHP's file naming conventions in the book.

    You can verify that this is the problem with the following code:

    if (get_class($this->Nailcolor) === 'AppModel') {
        die("app/Model/Nailcolor.php file not found");
    }
    

    how can I set the php.ini or cakephp settings

    There is no setting to to modify this behavior as it's inherited from the operating system (or more accurately from the format of the disk where the files are stored).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流