doushi9444 2016-02-22 11:03
浏览 52
已采纳

问题从Slim 2开始

I'm developing a web service using Slim Framework 2, it's the first time I use php. I'm having an issue with the Slim object:

There's my code:

require 'db.php';
require 'vendor/slim/slim/Slim/Slim.php';
echo 'require ok';
$app = new vendor/slim/slim/Slim();
echo '$app ok';

The 'require' lines are ok. But he $app line doesn't work I use the same path to the Slim.php file and also I've tryed to use this path:

$app = /slim/Slim();

The first echo is executing but the second one is not working. My ws.php file is on the same directori as the vendor folder:

vendor/slim/slim/Slim/
├── Environment.php
├── Exception
│   ├── Pass.php
│   └── Stop.php
├── Helper
│   └── Set.php
├── Http
│   ├── Cookies.php
│   ├── Headers.php
│   ├── Request.php
│   ├── Response.php
│   └── Util.php
├── Log.php
├── LogWriter.php
├── Middleware
│   ├── ContentTypes.php
│   ├── Flash.php
│   ├── MethodOverride.php
│   ├── PrettyExceptions.php
│   └── SessionCookie.php
├── Middleware.php
├── Route.php
├── Router.php
├── Slim.php
└── View.php

Is $app = new vendor/slim/slim/Slim(); correct? I'm lost about this topic.

Solved using Frank Martin solution:

require 'vendor/autoload.php';
$app = new \Slim\App;

Instead:

require 'vendor/slim/slim/Slim/Slim.php';
$app = new vendor/slim/slim/Slim();

Regards

  • 写回答

1条回答

  • dongmo6937 2016-02-22 11:22
    关注

    Make sure you've installed the composer dependencies then use this instead.

    require 'vendor/autoload.php';
    $app = new \Slim\App;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案