找不到Laravel 5模型类


Laravel 5 Model Class not found

我正试图将我的web应用程序从laravel 4移植到5,但我在我的一个模型类中没有找到问题。

我试图利用命名空间,并有以下我的模型,位于本地C:'xampp'htdocs'awsconfig'app'Models

出现错误的文件看起来像

<?php 
use App'Models'SecurityGroup;
function from_camel_case($input)
{
    preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
    $ret = $matches[0];
    foreach ($ret as &$match)
    {
        $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
    }
    return implode('_', $ret);
}
$resource_types = array();
$resource_types['AWS::EC2::Instance'] = 'EC2Instance';
$resource_types['AWS::EC2::NetworkInterface'] = 'EC2NetworkInterface';
$resource_types['AWS::EC2::VPC'] = 'VPC';
$resource_types['AWS::EC2::Volume'] = 'Volume';
$resource_types['AWS::EC2::SecurityGroup'] = 'SecurityGroup';
$resource_types['AWS::EC2::Subnet'] = 'Subnet';
$resource_types['AWS::EC2::RouteTable'] = 'RouteTable';
$resource_types['AWS::EC2::EIP'] = 'EIP';
$resource_types['AWS::EC2::NetworkAcl'] = 'NetworkAcl';
$resource_types['AWS::EC2::InternetGateway'] = 'InternetGateway';

 $accounts = DB::table('aws_account')->get();
 $account_list = array();


foreach(glob('../resources/sns messages/*.json') as $filename)
{
    //echo $filename;
    $data = file_get_contents($filename);
    if($data!=null)
    {

            $decoded=json_decode($data,true);  

            if(isset($decoded["Message"])) 
            { 
            //echo "found message<br>";
                $message= json_decode($decoded["Message"]);
if(isset($message->configurationItem))
{
//  echo"found cfi<br>";    
            $insert_array = array();
                $cfi = $message->configurationItem;
                switch ($cfi->configurationItemStatus)
                {
                    case "ResourceDiscovered":
                //echo"found Resource Discovered<br>";  
                        if (array_key_exists($cfi->resourceType,$resource_types))
                        {
                            //var_dump($cfi->resourceType);
                            $resource = new $resource_types[$cfi->resourceType];
                            foreach ($cfi->configuration as $key => $value)
                            {
                                if (in_array($key,$resource->fields))
                                {
                                    $insert_array[from_camel_case($key)] = $value;
                                }
                            }


                            $resource->populate($insert_array);
                            if (!$resource->checkExists())
                            {
                                $resource->save();
                                    if(isset($cfi->configuration->tags))
                                    {
                                       foreach ($cfi->configuration->tags as $t )
                                        {
                                        $tag= new Tag;
                                    $tag->resource_type = "instance";
                                    $tag->resource_id = $resource->id;
                                    $tag->key = $t->key;
                                    $tag->value = $t->value;
                                    $tag->save();

                                        /*if(isset($cfi->awsAccountId))
                                    {
                                     foreach ($accounts as $a)
                                     {
                                       $account_list = $a->account_id;
                                     }

                                    if (!in_array($account_id,$account_list))
                                    {

                                    $account_id = new Account;
                                    $account_id->aws_account_id = $cfi->awsAccountId;
                                    $account_list[] = $account_id;
                                     $account_id->save();
                                        }        



                                } */
                                }
                                }


                            }
                        }
                        else
                        {
                            echo "Creating ".$cfi["resourceType"]." not yet supported<br>";
                        }


                    break;
                    case 'ResourceDeleted':
                    //  echo"found Resource Deleted<br>";
                        //ITEM DELETED
                        if (array_key_exists($cfi->resourceType,$resource_types))
                        {
                            //var_dump($cfi->resourceType);
                                                        $resource = new $resource_types[$cfi->resourceType];

                            if ($resource->checkExists($cfi->resourceId))
                            {
                                $resource->delete();
                                  if( isset($cfi->configuration->tags))
                                      {
                                        foreach ($cfi->configuration->tags as $t )
                                            {
                                             $tag= new Tag;
                                              $tag->resource_type = "instance";
                                              $tag->resource_id = $resource->id;
                                              $tag->key = $t->key;
                                              $tag->value = $t->value;
                                              if ($tag->checkExists($cfi->configuration->tags))
                                              {
                                               $tag->delete();
                                              }
                                        }

                                     }
                        }
                        }
                        else
                        {
                            echo "Deleting ".$cfi["resourceType"]." not yet supported<br>";
                        }
                    break;
                    case 'OK':
                        //echo"found Resource OK<br>";
                        //ITEM UPDATED


                                               if (array_key_exists($cfi->resourceType, $resource_types))
                                                {
                            //var_dump($cfi->resourceType);
                                                        $resource = new $resource_types[$cfi->resourceType];
                                                        if ($resource->checkExists($cfi->resourceId))
                                                       {
                                                                foreach ($cfi->configuration as $key => $value)
                                                                {
                                                                        if (in_array($key,$resource->fields))
                                                                        {
                                                                                $update_array[from_camel_case($key)] = $value;
                                                                        }
                                                                }
                                $resource->populate($update_array);
                                                                $resource->save();
                                                        }        
                                                } 




                                                else
                                                {
                                                        echo "Updating ".$cfi["resourceType"]." not yet supported<br>";
                                                }
                    break;
                    default:
                        echo "Status ".$cfi['configurationItemStatus']." not yet supported<br>";
                    break;  
                    } 

            } 
        }
    }
}

和相应的模型,其类找不到,看起来像:

<?php namespace App'Models;
use Eloquent;
class SecurityGroup extends Eloquent
{
    protected   $table      = 'security_group';
    public      $timestamps = false;
    protected   $guarded    = array('id');
    public      $fields     = array('groupId',
                                    'groupName',
                                    'description',
                                    'ownerId'
                        );

    public function checkExists()
    {
        return self::where('group_id', $this->group_id)->first();
    }
    public function populate($array)
    {
        foreach ($array as $k => $v)
        {
            $this->$k = $v;
        }
    }
}

我不知道是什么导致了这个问题,我没有看到任何错字,但又有谁知道,一如既往地感谢给予的任何帮助。

解决资源类型需要完整的命名空间声明