slim

Authentication Based REST API with Slim

匆匆过客 提交于 2019-12-06 16:27:36
I'm not sure how to go with authentication method I have a way but don't know if it is secure or not. let me explain what I'm doing with REST API. I have a multiple users based web app, where users can login with their user name and password and do the stuff. I need to develop a mobile app for that web app. I'm thinking REST with Slim Framework, However I have no problem with Slim REST development but the authentication part is what I am not sure how to develop. However I have some idea Use session cookies :- When user login via mobile app call REST API authentication method, make database

Nginx configuration with Slim Framework, How to keep the .php url

为君一笑 提交于 2019-12-06 14:54:05
My server has just wiped out by the provider, and I don't have the backup of the Nginx configuration file. It was completely lucky I got it working, now I don't know what to do. So I am having multiple files to do some specific things, and I am using Slim Framework on each file. The idea is to keep the php extension on the URL. Something like this: www.example.com/service.php/customer/1 www.example.com/api.php/data www.example.com/test.php/other-data/5 Does anyone have some clue on this? I really forgot what I did before with the configuration. Thank you in advance If somehow someone goes here

SLIM Framework - How to make an Access Control List with SLIM?

旧时模样 提交于 2019-12-06 14:35:17
问题 An Access Control List, or ACL, defines the set of rules that determines which group of users have access to which routes within your Slim application. Any idea how to use Access Control List with SLIM ? I try to create Access Control List for my REST API Authorization. Example : Role member only can access GET,UPDATE from resource (/member) Admin member only can access GET,UPDATE,POST,DELETE from resource (/admin) Any idea how to do it with SLIM ? 回答1: Still learning but... In my Slim routes

How to trigger Eloquent Manager in Slim 3.1 Dependency Injection

故事扮演 提交于 2019-12-06 11:45:55
I have write my code to instantiate Eloquent Capsule/Manager using slim DI like this $container['db'] = function ($c) { $settings = $c->get('database'); $db = new \Illuminate\Database\Capsule\Manager; $db->addConnection($settings); $db->setAsGlobal(); $db->bootEloquent(); return $db; } And I have my route like this $app->get('/adduser', function() { $user = new Users; $user->name = "Users 1"; $user->email = "user1@test.com"; $user->password = "My Passwd"; $user->save(); echo "Hello, $user->name !"; }); When I run the route in browser it will produce error in web server error log PHP Fatal

Download file from Slim Framework 2.4

主宰稳场 提交于 2019-12-06 08:12:39
I am trying to let the user download a file in the Slim php framework. The intended use is that the file will be: http://api.test.com/item/123.json <- returns json string with data http://api.test.com/item/123.pdf <- download pdf-file with human-readable presentation of data I have the code producing the PDF, but what I need is to make Slim send the correct headers so the file will be downloaded. This is the following code I have (working) for the existing system: header("Pragma: public"); header('Content-disposition: attachment; filename='.$f->name); header('Content-type: ' .$f->type); header

PHP Slim Framework Create Controller

十年热恋 提交于 2019-12-06 07:28:07
问题 I am creating an API using the Slim framework. Currently I use a single file to create the route and pass a closure to it: $app->get('/', function($req, $resp){ //Code... }) But I realise that my file has grown rapidly. What I want to do is use controllers instead, so I will have a controller class and just pass the instance/static methods to the route, like below class HomeController { public static function index($req, $resp){} } and then pass the function to the route $app->get('/',

Cannot access Eloquent attributes on Twig

不羁的心 提交于 2019-12-06 06:57:12
问题 I am trying to access an Eloquent attribute with Twig in Slim, and getting an error. I have a Field and a Type object, and the relationship is as follows class Field extends \Illuminate\Database\Eloquent\Model { protected $table = 'fields'; public function type() { return $this->belongsTo('models\Type'); } When doing {{ f }} (being f a field), the output is this: {"field_id":"1","field_name":"Your name","form_id":"2","type_id":"1","placeholder":"Please give us your name"} And when doing {{ f

Character encoding error for .php file

不打扰是莪最后的温柔 提交于 2019-12-06 03:57:43
问题 Have made a route for MarkersController.php which returns json, but when i navigate to the route I get the following error: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. My route is as follows: $app->get('/markers/?', function () use ($app)

How to include JS/CSS files into templates of Slim Framework?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 02:31:25
I am developing a simple web app with Slim framework. I got stuck with a probably simple problem. I want to include static files (CSS and Javascript) into my template. My project folder structure is as follows: index.php //<=== where all the routing happens. /flot layout.css jquery.js .... /templates first_template.php My header of first_template.php contains: <link href="../flot/layout.css" rel="stylesheet" type="text/css"> <script language="javascript" type="text/javascript" src="../flot/jquery.js"></script> When I call the projects root url http://localhost/xampp/ProjectX/ (I'm using XAMPP)

How can I composer update on OpenShift?

三世轮回 提交于 2019-12-05 21:49:43
I am trying to use Slim on OpenShift with a free node. I can run composer update from the SSH sessions without any problem. The only problem is every time I want to commit files through git I have to go to the console and run composer install again. My question is there is any easy way to workaround this? I tried a BASH script in /project/.openshift/action_hooks/post_deploy but the server is not creating the vendor folder under runtime/repo I always do it via action hooks : Inside my project directory I have a script called by /project/.openshift/action_hooks/post_deploy where post_deploy is a