使用命名空间出错

时间:2016-09-16 15:54:55

标签: php namespaces

我的命名空间出现以下错误。我已经搜索并尝试实施我找到的所有解决方案,但我无法解决。

错误:

  

致命错误:未捕获错误:类' App \ Models \ Site \ User'在第4行的/Applications/MAMP/htdocs/php-sem-medo/ORM/index.php中找不到

的index.php

org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet
Caused by: org.apache.felix.log.LogException: org.osgi.framework.ServiceException: Service cannot be cast: javax.servlet.Servlet
    at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:344)
    at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:231)
    at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:327)
    at org.apache.felix.framework.Felix.getService(Felix.java:3574)
    at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)
    at org.osgi.util.tracker.ServiceTracker.addingService(ServiceTracker.java:411)
    at org.apache.felix.http.whiteboard.internal.tracker.AbstractTracker.addingService(AbstractTracker.java:35)
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
    at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:894)
    at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:943)
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:794)
    at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544)
    ... 12 more

Model.php

<?php
    require_once "config.php";
    use App\Models\Site\User as User;
    $user = new User;
    dump($user -> all());
?>

user.php的

<?php
    namespace App\Models{
        class Model extends \ActiveRecord\Model { };
    }
?>

composer.json

<?php
    namespace App\Models\Site{
        use App\Models\Model;
        class User extends Model {
            static $table_name = 'users';
        }
    }
?>

的config.php

{
    "require": {
        "php-activerecord/php-activerecord": "^1.1"
    },
    "autoload":{
        "psr-4":{
            "App\\":"App"
        }
    }
}

目录结构

<?php
    require_once 'vendor/autoload.php'; 
    require_once 'connection.php';
?>

2 个答案:

答案 0 :(得分:0)

Add-PSSnapin CloudBerryLab.Explorer.PSSnapIn Set-CloudOption -ProxyAddress xxxx -ProxyPort xxxx -PathStyle Path $key = "xxxx" $secret = "xxxx" $s3 = Get-CloudS3Connection -Key $key -Secret $secret $source = $s3 | Select-CloudFolder -path TestAutoSync/backup 需要文件的完整路径,而不仅仅是文件名。

尝试连接插件目录和文件名

答案 1 :(得分:0)

我解决了我的问题,显然它自己的代码没有任何问题。我不得不在项目目录中运行以下命令......

composer dump-autoload

之后问题解决了,我可以访问所需的信息。