slim

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

ε祈祈猫儿з 提交于 2019-12-02 05:28:34
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: Fatal error: Class 'Slim\Slim' not found in C:... Any ideas what have I missed? khartnett If you prefer

AngularJS - PUT method not working (404 error)

泄露秘密 提交于 2019-12-02 02:30:37
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', function($resource) { return $resource('/api/main/actions/:actionid', {}, { 'update': { method: 'PUT

Organize routes into separate files not working properly in Slim

我们两清 提交于 2019-12-02 00:56:54
问题 This is my Index.php file: use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response; require '../vendor/autoload.php'; require '../src/config/db.php'; $app = new \Slim\App; //User Routes require '../src/routes/users.php'; // This not working require '../src/routes/org.php'; // Only This working $app->run(); .htaccess file RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]

Data is not getting updated in the view after promise is resolved

帅比萌擦擦* 提交于 2019-12-02 00:52:22
I am using my Rails app as an API backend. So I have a single page angular app which will make multiple api calls and start displaying as each data gets returned. I don't want to wait for all the results from the API call and then load the data, so I started learning deferred and promise. I have an angular service called api where I will have $http calls to all my api. I have hardcoded the data that returns from each one of the api calls for testing purposes. debugger.factory "api", ["$resource", "$q", ($resource, $q) -> apiCall1 = [ key1: "v1" key2: "v2" key3: "v3" ] apiCall2 = . . . apiCall7

Organize routes into separate files not working properly in Slim

ε祈祈猫儿з 提交于 2019-12-02 00:00:17
This is my Index.php file: use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response; require '../vendor/autoload.php'; require '../src/config/db.php'; $app = new \Slim\App; //User Routes require '../src/routes/users.php'; // This not working require '../src/routes/org.php'; // Only This working $app->run(); .htaccess file RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L] When there is only one require file it's working fine but when adding two or multiple files then only

How can i create middleware on Slim Framework 3?

为君一笑 提交于 2019-12-01 14:53:29
I read the documentation here about creating middleware. But which folder or file i must be create it? Documentation is not contain this information. Under the src folder i have middleware.php . For example i want to get post information like this: $app->post('/search/{keywords}', function ($request, $response, $args) { $data = $request->getParsedBody(); //Here is some codes connecting db etc... return json_encode($query_response); }); i made this under the routes.php but i want to create class or middleware for this. How can i do? Which folder or file i must be use. Slim3 does not tie you to

Get PUT params with Slim PHP

若如初见. 提交于 2019-12-01 14:51:04
问题 I searched, but I didn't find an answer. I have a RESTful API to manage a basic CRUD. I'm trying to create an update method using PUT, but I can't retrieve the params values. I'm using Postman to make the requests, my request looks like: URL http://localhost/api/update/987654321 Params id = 987654321 name = John Smith age = 35 PHP $app = new Slim(); $app->put('/update/:id', function( $id ) use( $app ){ var_dump([ 'id' => $id, 'name' => $app->request->put('name'), 'age' => $app->request->put(

How can i create middleware on Slim Framework 3?

纵然是瞬间 提交于 2019-12-01 14:24:38
问题 I read the documentation here about creating middleware. But which folder or file i must be create it? Documentation is not contain this information. Under the src folder i have middleware.php . For example i want to get post information like this: $app->post('/search/{keywords}', function ($request, $response, $args) { $data = $request->getParsedBody(); //Here is some codes connecting db etc... return json_encode($query_response); }); i made this under the routes.php but i want to create

How to send a URL in route parameter?

让人想犯罪 __ 提交于 2019-12-01 12:01:50
问题 I have defined a route like this : $app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) { return $response; })->add(new CustomMiddleware()); Its working fine when I pass a url without http:// but gives me a 404 page not found -Page with http:// or https:// . I have also tried with url encoded string but gives same error : http://localhost/slim/public/index.php/abc/http%3A%2F%2Fstackoverflow.com The requested URL /slim/public/index.php/abc/http://stackoverflow.com

how to Mod-rewrite php + Slim url to sub-directory

柔情痞子 提交于 2019-12-01 11:49:45
I am using Slim 2.4 and php 5.3. My Directory Structure in localhost is something like this : Web Root AppName API v1 include Slim <- Slim Framework tools .htaccess (#1) index.php (#1) Assets css js img .htaccess (#2) index.php (#2) I wan to access localhost/AppName/v1 that will open up localhost/AppName/API/v1 . This is working partially as further parameters are getting ignored. When I am trying to get localhost/AppName/v1/anyOtherVariable it opens up localhost/AppName/API/v1 only. Now, #1 index.php contains all Slim code (routing and stuff) but #1 .htaccess is blank. #2 index.php contains a