slim

How can I deliver an error page in Slim framework when an Exception is thrown outside of a route?

[亡魂溺海] 提交于 2019-12-22 09:15:34
问题 I'm trying to wrap my head around the order of operations for dealing with Exceptions thrown in a Slim framework app and the final page delivery. Basically, if I throw an Exception in a class I'd like Slim to deliver my pretty Twig 500 page, but I can't even get Slim to deliver its own normal error page when an exception is thrown outside of a route. Given this database class constructor: public function __construct(array $connection, \Slim\Slim $slim) { $this->slim = $slim; try { $this->db =

hooks versus middleware in slim 2.0

巧了我就是萌 提交于 2019-12-22 05:40:35
问题 Can anyone explain if there are any significant advantages or disadvantages when choosing to implement features such as authentication or caching etc using hooks as opposed to using middleware? For instance - I can implement a translation feature by obtaining the request object through custom middleware and setting an app language variable that can be used to load the correct translation file when the app executes. Or I can add a hook before the routing and read the request variable and then

Uploading file over https with cordova filetransfer

会有一股神秘感。 提交于 2019-12-22 01:05:39
问题 I've got a problem with the file transfer plugin that i can't seem to figure out. My code works when i'm using http, but when I try to upload over https it seems that it doesn't send the parameters to my api but it does reach my api. only the the file is missing, the x-session-token header is present and valid. This is the code i use for uploading the file: $scope.options = {}; $scope.options.fileKey = "file"; $scope.options.fileName = $scope.img.substr($scope.img.lastIndexOf('/') + 1);

How to respond in Middleware Slim PHP Framework

南笙酒味 提交于 2019-12-21 05:33:39
问题 I am creating middleware for auth into REST API. My API is created using Slim PHP Framework ,which in case provide great features to build APIs. One of this feature is Middleware. I need to check credentials in Middleware and respond with an error (HTTP code with JSON descriptions) to the user. But unfortunatly Slim Framework gives me an exception whenever I try to halt and respond with the HTTP code. <?php require_once __DIR__.'/../Slim/Middleware.php'; class TokenAuth extends \Slim

Securing a REST API and Slim Framework

大憨熊 提交于 2019-12-20 08:43:10
问题 I am fairly new to REST APIs, and I realize there are quite a few questions already posted. However, perusing these has actually left me more confused on how to handle this. I have created a REST API using Slim Framework which I am simply using to transfer data. I won't be using user logins or authentication, so I believe to secure this I just need a system that using a public key and a private key, but I am just not sure. If anyone has insight on the correct / most secure way to do this, or

slim 3 php application not working on CentOS nginx access denied possibly due to session_start() function

泪湿孤枕 提交于 2019-12-20 06:32:14
问题 I have been struggling lately on installing latest nginx 1.14, php 7.2.5 and mariaDB 10.3.7 on CentOS 7 on virtualbox on macOS. Finally php is working, I have already tested php_info() , index.php , testDBconnection.php successfully and even redirecting to a /public folder. However, when copying my Slim 3 application to folder, I get this error: access denied I access the log via # tail /var/log/nginx/error.log and the output is the following: PHP message: PHP Warning: session_start(): Failed

slim 3 php application not working on CentOS nginx access denied possibly due to session_start() function

元气小坏坏 提交于 2019-12-20 06:30:06
问题 I have been struggling lately on installing latest nginx 1.14, php 7.2.5 and mariaDB 10.3.7 on CentOS 7 on virtualbox on macOS. Finally php is working, I have already tested php_info() , index.php , testDBconnection.php successfully and even redirecting to a /public folder. However, when copying my Slim 3 application to folder, I get this error: access denied I access the log via # tail /var/log/nginx/error.log and the output is the following: PHP message: PHP Warning: session_start(): Failed

Composer autoloader + slim framework - fatal error: Class 'Slim\Slim' not found?

三世轮回 提交于 2019-12-20 04:22:25
问题 How can I use composer autoloader to load slim? I have it a go below, composer.json: { "autoload": { "psr-4": { "Vendor\\Namespace\\": "" } } } index.php: require dirname(__FILE__).'/vendor/autoload.php'; use \Slim\Slim; Slim::registerAutoloader(); //Instantiate a Slim application: $app = new Slim(); //Define a HTTP GET route: $app->get('/', function () { echo "Hello!"; }); $app->get('/hello/:name/', function ($name) { echo "Hello, $name"; }); //Run the Slim application: $app->run(); error:

AngularJS - PUT method not working (404 error)

吃可爱长大的小学妹 提交于 2019-12-20 02:58:05
问题 I'm new to AngularJS and I have trouble to update an object via REST. I'm using a PHP/Mysql Backend (Slim Framework). I'm able to retrieve (GET), create (POST) a new object but not to edit (PUT) one. Here's the code: my Form: <form name="actionForm" novalidate ng-submit="submitAction();"> Name: <input type="text" ng-model="action.name" name="name" required> <input type="submit"> </form> My service: var AppServices = angular.module('AppServices', ['ngResource']) AppServices.factory('appFactory

Routing with AngularJS and Slim PHP

吃可爱长大的小学妹 提交于 2019-12-19 04:18:19
问题 I have been working with AngularJS and I am trying to connect my application to it. So far I have used Slim PHP and can get all records from my MySql database but I am not able to get a specific record. I have written the PHP code and can navigate to "../requests/#" and get a JSON response of the correct ID record. What I cant get is it to work with the interface. With the code below I can create a list of requests and click on the one I want to open viewRequest.html. However my view request