slim

AJAX post in using slim framework outputs 500 (Internal Server Error)

萝らか妹 提交于 2019-12-11 19:48:10
问题 I have been stuck on this for days now, here is my previous question, but none of the comments seem to work. I have tried multiple things and managed to get rid of the 404 error, but now there is a 500 error... Basically I want to post an AJAX query when an event happens. Run a Slim post route using the AJAX query parsing through a value. Select data from the database using the Slim post route using the parsed through value. Then return the results from the query and display them in a

Changing text based on the final letter of user name

落花浮王杯 提交于 2019-12-11 17:15:23
问题 In my system, users will register their names. In the natural language the system is used with, names end differently depending its use, such as: who: "name surname" with who: "namai surnamai" Due to this, I need to change the ending of @provider_user.name in some places; if it ends with e , replace e with ai . My HTML slim code is: = render partial: 'services/partials/messages/original_message', locals: { header: t('html.text.consultation_with.for_provider', name: @provider_user.name) It

SLIM framework Halt call

送分小仙女□ 提交于 2019-12-11 16:47:05
问题 Have a question on Slim Framework php. In my application, I would like to stop the application execution if a condition is mismatched. There is a halt function, per Slim documentation. But that does not appear to be working. the application continuous to execute even after calling Halt. pseudo code: if ( $valid ) { // Do something } else { $app->halt(500, "not valid"); } // Other code here. $app->run(); I was expecting that, we we call Halt function, the "Other code" should not execute. But

PHP Slim 3 Framework - Use MonoLog in Custom Class - Using $this when not in object context

喜欢而已 提交于 2019-12-11 16:38:28
问题 Im am working from the Slim 3 skeleton and trying to use the MonoLog in a custom class I have created which is called Utilities. Utilities.php - which is required from index.php <?php class Utilities { protected $logger; function __construct($c) { $this->logger = $logger; } static function checkPerms() { $this->logger->info("checkPerms() permissions of user id valid."); return true; } } Dependencies.php - I added the following: $container['utilities'] = function ($c) { return new Utilities($c

Nginx slim framework keep pointing to the main index in root folder

元气小坏坏 提交于 2019-12-11 16:34:04
问题 I am trying to set the slimframework on nginx webserver. Below is my current settings. I am using the slim/slim-skeleton. Whenever I run e.g. http://myip/apiv1 it points to the index.php in /var/www/html. Even I run anything example http://myip/apiv1/token its the same as above. I tried changing the root /var/www/html/apiv1/public; to alias /var/www/html/apiv1/public; its the same. What else does nginx require any special settings. user nginx; worker_processes auto; error_log /var/log/nginx

Slim Framework Rest service getting output twice

让人想犯罪 __ 提交于 2019-12-11 10:12:59
问题 I'm making a REST service with php using the slim framework. everything works but there is something weird. I always get double or triple data. Here is my index.php: <?php require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { header( "HTTP/1.1 200 OK" ); exit(); } function getConnection() { try { $db_username = "root"; $db_password="admin"; $conn = new PDO('mysql:host=localhost;dbname=dats24', $db_username); $conn-

How do I set a JSON header in Slim 3 framework (PHP)?

坚强是说给别人听的谎言 提交于 2019-12-11 09:56:02
问题 How do I set a JSON header in Slim 3? $app->get('/joinable', function ($request, $response, $args) { header('Content-Type: application/json'); return getJoinable(); // Returns JSON_encoded data }); I have tried the following $response = $app->response(); $response['Content-Type'] = 'application/json'; $app->contentType('application/json'); 回答1: Never used Slim framework, but according to their documentation, it should be something in the lines of: $app->get('/joinable', function ($request,

doctrine dbal get latest chat message per group [duplicate]

▼魔方 西西 提交于 2019-12-11 07:40:02
问题 This question already has answers here : Doctrine Query Language get Max/Latest Row Per Group (4 answers) Closed 2 years ago . when trying make multiple select $result = $this->qb->select('c.id','c.message','acc.name as chat_from', 'c.chat_to as count') ->addSelect("SELECT * FROM chat ORDER BY date_deliver DESC") ->from($this->table,'c') ->join('c','account','acc', 'c.chat_from = acc.id') ->orderBy('date_sent','DESC') ->groupby('chat_from') ->where('chat_to ='.$id) ->execute(); return $result

Slim framework and email template rendering issue with PHPmailer

泄露秘密 提交于 2019-12-11 07:33:20
问题 I am using Slim v3 php framework and have integrated PHPMailer to send mails. I don't use any template engine like Twig, but I rather use plain PHP. My idea is to make a HTML5 template for emails in a separate file, similar to regular page templates and then pass some variables into it, render it and send it. It all works well except for one part - rendered output also has rendered header info. This is how my code looks like, simplified of course // Store variables in an array $email_content

net::ERR_CONNECTION_REFUSED Slim Framework

馋奶兔 提交于 2019-12-11 07:31:48
问题 so this is it. I am running my API on a server, its running in localhost:8080 in the server. I was told that in order to access the api from locally from my machinne (using vpn) the url is xxx.xxx.xxx:8080 So i tried that $http({ url:'http://xxx.xxx.xxx.xxx:8080/login', method:"POST", data:{user:$scope.user, password:$scope.password} }) and my api route is like this $app->post('/login', function ($request, $response) { //Parametros que se pasan a la api $input = $request->getParsedBody();