当前位置: 首页 > 工具软件 > phprs > 使用案例 >

php exception not found,求助,"error":"phprs\\util\\exceptions\\NotFound","message

弘承业
2023-12-01

`<?php

header("Content-Type:text/html;charset=utf-8");

use phprs\ezsql\Sql;

/**

*

@path("/wwwwwww")

/

class HelloWorld2

{

/*

@route({"GET","/"})

@param({"arg0","$._GET.arg0"})

*/

public function doSomething1() {

try{

$pdo = $this->db;

$str = Sql::update('report')->set( 'lv = 1' )->where('id=?',$arg0)->exec($pdo);

$pdo->commit();

}

catch (Exception $e) {

$pdo->rollBack();

throw $e;

}

return "1";

}

/**

@Property({"default":"@db"}) 注入pdo实例

*/

public $db;

}

`

这是我在phprs-restful-master\example\apis目录下新建的Helloworld2.php 文件 不知道为什么访问会报 30.0202877496header ( )..\Bootstrap.php:42

{"error":"phprs\util\exceptions\NotFound","message":""}

我把 HelloWorld.php 内容改成了

`<?php

header("Content-Type:text/html;charset=utf-8");

use phprs\ezsql\Sql;

/**

*

@path("/g")

/

class HelloWorld

{

/*

@route({"GET","/"})

/

public function doSomething1() {

$str = Sql::select('')->from('report')->where( 'lv = 0' )->limit(1,1)->get($this->db);

$str1= json_encode($str, JSON_UNESCAPED_UNICODE);

return $str1;

}

/**

@Property({"default":"@db"}) 注入pdo实例

*/

public $db;

}`

这样访问又没有问题。真是奇怪,

配置文件 phprs-restful-master\example\conf.php内容

`<?php

return [

"phprs\Router"=>[

"properties"=>[

"export_apis"=>true,

"url_begin"=>1,

"api_path"=>DIR.'/apis/',

]

],

"phprs\\Invoker"=>[

"properties"=>[

]

],

"db"=>[

"singleton"=>true,

"class"=>"PDO",

"pass_by_construct"=>true,

"properties"=>[

"dsn"=>"mysql:host=127.0.0.1;dbname=report;charset=UTF8",

"username"=>"root",

"passwd"=>"xxx"

]

]

];

`

 类似资料: