slim

Slim PUT returns NULL

早过忘川 提交于 2019-12-11 02:21:50
问题 I have a problem with the Slim Framework and a PUT request. I have a litte jQuery script that that will update an expiry time when a button is clicked. $("#expiry-button").click(function(event) { event.preventDefault(); $.ajax({ url: 'http://www.domain.com/expiry/38/', dataType: 'json', type: 'PUT', contentType: 'application/json', data: {aid:'38'}, success: function(){ var text = "Time updated"; $('#expiry').text(text).addClass("ok"); }, error: function(data) { var text = "Something went

Unable to call API of slim framework

别来无恙 提交于 2019-12-11 02:07:55
问题 I am designing an API in PHP using slim framework. These are working fine on my local system and my public IP. But now I upload these APIs files on to my company server. Now I am trying to access API stored on my company's server but these are showing empty pages, this means I am unable to call API. Here is the API <?php include('connect.php'); header('Content-type: text/xml'); header('Content-type: application/json'); // Include the Slim library require 'Slim/Slim.php'; // Instantiate the

Slim Basic Authentication

怎甘沉沦 提交于 2019-12-11 00:46:26
问题 Good day everyone! I have a working slim code here with slim-basic-auth and when I go to a restricted directory, this shows up: Everything works, but what I wanted to do is to redirect it to my login page instead of showing a popup login box. Here is my login page: My slim code: $pdo = new \PDO("mysql:host=localhost;dbname=databasename", "username"); $app->add(new \Slim\Middleware\HttpBasicAuthentication([ "path" => "/main", "realm" => "Protected", "authenticator" => new PdoAuthenticator([

How to group a specific field in array?

假如想象 提交于 2019-12-11 00:39:58
问题 I need to get the trophies won by a team, each trophy is achieved in a competition into a specific season, but a team can win a trophy for the same competition per different seasons. I wrote a query that extract the trophies from the database: $sql = $this->db->prepare("SELECT t.*, s.*, c.*, t.team_id as team_id, s.id as season_id, s.name as season_name, c.id as competition_id, c.name as competition_name FROM team_trophies t INNER JOIN competition_seasons s ON s.id = t.season_id INNER JOIN

htaccess slim and angular2

不想你离开。 提交于 2019-12-10 23:28:18
问题 I have problems with a htaccess, maybe you can help me. My system consists of an angular2-app (single page client side app, index.html) and a slim-v3 php REST API (index.php). The angular2-app accesses the REST API. If possible, then I would like to use the same domain for the angular2-app and the slim REST API. At the moment, the htaccess looks like this: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST

Slim 3 - Slash as a part of route parameter

安稳与你 提交于 2019-12-10 16:17:53
问题 I need to compose URLs with parameters that can contain a slash /. For example, the classic /hello/{username} route. By default, /hello/Fabien will match this route but not /hello/Fabien/Kris . I would to ask you how can I do it in Slim 3 framework. 回答1: Route placeholders: For “Unlimited” optional parameters, you can do this: $app->get('/hello[/{params:.*}]', function ($request, $response, $args) { $params = explode('/', $request->getAttribute('params')); // $params is an array of all the

Slim Framework redirect with params

若如初见. 提交于 2019-12-10 14:28:22
问题 I'm using Slim framework for the first time, and so far everything is spot on. But there is one thing I can't seem to get my head around. After posting a form I would like to redirect back to the same page, but it uses a param in the url and I can't get back to it. This is what I have so far: $app->post('/markets-:game', $authenticated(), function($game) use ($app) { $request = $app->request(); $id = $request->post('game3'); $app->flash('global', 'game added'); $app->response->redirect($app-

Slim Framework: routes and controllers

妖精的绣舞 提交于 2019-12-09 19:00:39
问题 Originally, my Slim Framework app had the classic structure (index.php) <?php $app = new \Slim\Slim(); $app->get('/hello/:name', function ($name) { echo "Hello, $name"; }); $app->run(); But as I added more routes and groups of routes, I moved to a controller based approach: index.php <?php $app = new \Slim\Slim(); $app->get('/hello/:name', 'HelloController::hello'); $app->run(); HelloController.php <?php class HelloController { public static function hello($name) { echo "Hello, $name"; } }

No 'Access-Control-Allow-Origin' header is present

半世苍凉 提交于 2019-12-08 09:07:14
问题 I am using angular.js to make a ReSTful app for mobile devices using cordova. for server side I am using slim framework.all according to this tutorial:(http://www.angularcode.com/user-authentication-using-angularjs-php-mysql/) But when i uploaded api folder to server, error occurs : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost' is therefore not allowed access. The response had HTTP status code 404. I have read about adding "Access-Control

Routing issue with Slim framework

给你一囗甜甜゛ 提交于 2019-12-08 08:57:29
问题 I just got started with Slim. My application for the moment is something like this: <?php require 'vendor/autoload.php'; $app = new \Slim\Slim([ 'debug' => true ]); var_dump($app->request()); $app->get('/:name', function ($name) { echo "Hello, $name"; }); $app->get('/', function () { echo 'hello world'; }); $app->run(); I am running it on localhost using PHP built in web server. For every request I try in the browser (or Postman, or CURL), what I get is always "hello world", as if the first