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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置