Giter Site home page Giter Site logo

support命名空间问题 about webman HOT 9 CLOSED

lscho avatar lscho commented on May 24, 2024
support命名空间问题

from webman.

Comments (9)

walkor avatar walkor commented on May 24, 2024

这边没有好的办法

from webman.

lscho avatar lscho commented on May 24, 2024

未来会优化吗

from webman.

walkor avatar walkor commented on May 24, 2024

你自定义了哪个文件

from webman.

walkor avatar walkor commented on May 24, 2024

phpstom我这自定义了本地目录的 support\Request::get方法,代码提示和跳转都是跳转都是正确的。

from webman.

lscho avatar lscho commented on May 24, 2024

我定义的是Model,用了thinkORM ,但编辑器还是会提示illuminate的方法。编辑器是VScode

from webman.

walkor avatar walkor commented on May 24, 2024

没必要用 support/Model,建议用 app/Model,support目录里尽量不放代码,所有代码尽量放在app目录下。

from webman.

lscho avatar lscho commented on May 24, 2024

是因为默认情况下,即使安装了thinkORM ,但代码提示还是提示的 illuminate。所以我才 support/Model 覆盖了一下框架自带的命名空间。但是这样虽然thinkORM 的方法会提示,illuminate的方法也会提示,导致有些情况下代码提示就很乱。

from webman.

walkor avatar walkor commented on May 24, 2024

我觉得你是弄错了,根据thinkorm手册,thinkorm使用 think\Model;,不应该使用support\Model
如果你要自己定义一个自己的thinkorm model的基类,把基类放到app目录下,比如

namespace app;

class Model extends \think\Model
{
   
}

和support/Model 一点关系都没有,我觉得vscode不会这么蠢到提示到support/Model上去

from webman.

lscho avatar lscho commented on May 24, 2024

抱歉,重新看了遍文档,可能我理解错了。我以为在项目目录 support 下面加载了一个文件之后,框架里 support 下面的同名文件就不加载了。但是文档说的只是优先加载项目目录的文件。所以我下面的用法应该是错的。

我需要扩充模型的一些方法。所以我在 support\Model.php 写了如下代码:

<?php
namespace support;

use think\Model as BaseModel;

class Model extends BaseModel
{

}

然后在模型中

<?php

namespace app\model;

use support\Model;

class Test extends Model
{
    protected $table = 'test';
}

这样会导致模型同时提示ThinkORM和Eloquent ORM的一些方法。

我把support\Model.php改成support\ThinkORM.php,然后模型继承 ThinkORM 就正常了。

from webman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.