Closed jricher-dev closed 7 years ago
Both seem to work fine.
require __DIR__ . "/vendor/autoload.php";
use \Slim\App;
$app = new App();
$app->get("/i18n", function($request, $response, $args){
echo "i18n working";
});
$app->run();
$ curl --include http://localhost:8080/i18n
HTTP/1.1 200 OK
Host: localhost:8080
Connection: close
X-Powered-By: PHP/7.0.11
Content-Type: text/html; charset=UTF-8
Content-Length: 12
i18n working
require __DIR__ . "/vendor/autoload.php";
use \Slim\App;
$app = new App();
$app->get("/I18n", function($request, $response, $args){
echo "I18n working";
});
$app->run();
$ curl --include http://localhost:8080/I18n
HTTP/1.1 200 OK
Host: localhost:8080
Connection: close
X-Powered-By: PHP/7.0.11
Content-Type: text/html; charset=UTF-8
Content-Length: 12
I18n working
Hum ok in other server it work. is it possible that the problem is the .htaccess file?
How does your .htaccess
file look? What do you see in access_log
and error_log
when you request /i18n
. Do you actually request /i18n
or something else for example /i18n/
. Do you actually call $app->run()
somehwere in your code.
Also define "does not work".
this is index.php :
<?php
require 'vendor/autoload.php';
use \Slim\App;
$app = new App();
$app->get('/', function($request, $response, $args){
echo '<p>bienvenue</>';
});
$app->get("/i18n", function($request, $response, $args){
echo "i18n working";
});
$app->get("/I18n", function($request, $response, $args){
echo "I18n working";
});
$app->get('/i18n/{filename:[A-Z_]+}', function($request, $response, $args){
include 'google_OAuth.php';
$fichier = $args['filename'];
$response = $service->files->listFiles(array(
'q' => "name contains '$fichier'",
'spaces' => 'drive'));
foreach ($response->files as $file) {
if ($file->name == $fichier ) {
echo 'le fichier distant ' . $fichier . ' existe sur google Drive';
}
}
});
$app->get('/download/{filename:[A-Z_]+}', function($request, $response, $args){
include 'google_OAuth.php';
$fichier = $args['filename'];
$response = $service->files->listFiles(array(
'q' => "name contains '$fichier'",
'spaces' => 'drive'));
foreach ($response->files as $file) {
$content = $service->files->export($file->id, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', array(
'alt' => 'media' ));
file_put_contents('tmp/' . $fichier . '.xls', $content->getBody()->getContents());
header('Location: /');
exit();
}
});
$app->run();
this is .htaccess :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
i have test it with :
echo getenv('SCRIPT_NAME');
var_dump($_SERVER);
die('stop');
in my index.php and for http://0.0.0.0:8080/I18n i have :
array(22) {
["DOCUMENT_ROOT"]=>
string(28) "/home/xxx/nx-i18n-storage"
["REMOTE_ADDR"]=>
string(9) "127.0.0.1"
["REMOTE_PORT"]=>
string(5) "37180"
["SERVER_SOFTWARE"]=>
string(45) "PHP 7.0.8-0ubuntu0.16.04.3 Development Server"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["SERVER_NAME"]=>
string(7) "0.0.0.0"
["SERVER_PORT"]=>
string(4) "8080"
["REQUEST_URI"]=>
string(5) "/I18n"
["REQUEST_METHOD"]=>
string(3) "GET"
["SCRIPT_NAME"]=>
string(10) "/index.php"
["SCRIPT_FILENAME"]=>
string(38) "/home/xxx/nx-i18n-storage/index.php"
["PATH_INFO"]=>
string(5) "/I18n"
["PHP_SELF"]=>
string(15) "/index.php/I18n"
["HTTP_HOST"]=>
string(12) "0.0.0.0:8080"
["HTTP_USER_AGENT"]=>
string(76) "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"
["HTTP_ACCEPT"]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.5"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_UPGRADE_INSECURE_REQUESTS"]=>
string(1) "1"
["REQUEST_TIME_FLOAT"]=>
float(1476974903.1569)
["REQUEST_TIME"]=>
int(1476974903)
}
stop
but for http://0.0.0.0:8080/i18n i have :
array(21) {
["DOCUMENT_ROOT"]=>
string(28) "/home/xxx/nx-i18n-storage"
["REMOTE_ADDR"]=>
string(9) "127.0.0.1"
["REMOTE_PORT"]=>
string(5) "37186"
["SERVER_SOFTWARE"]=>
string(45) "PHP 7.0.8-0ubuntu0.16.04.3 Development Server"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["SERVER_NAME"]=>
string(7) "0.0.0.0"
["SERVER_PORT"]=>
string(4) "8080"
["REQUEST_URI"]=>
string(5) "/i18n"
["REQUEST_METHOD"]=>
string(3) "GET"
["SCRIPT_NAME"]=>
string(5) "/i18n"
["SCRIPT_FILENAME"]=>
string(38) "/home/xxx/nx-i18n-storage/index.php"
["PHP_SELF"]=>
string(5) "/i18n"
["HTTP_HOST"]=>
string(12) "0.0.0.0:8080"
["HTTP_USER_AGENT"]=>
string(76) "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"
["HTTP_ACCEPT"]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.5"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_UPGRADE_INSECURE_REQUESTS"]=>
string(1) "1"array(21) {
["DOCUMENT_ROOT"]=>
string(28) "/home/xxx/nx-i18n-storage"
["REMOTE_ADDR"]=>
string(9) "127.0.0.1"
["REMOTE_PORT"]=>
string(5) "37186"
["SERVER_SOFTWARE"]=>
string(45) "PHP 7.0.8-0ubuntu0.16.04.3 Development Server"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["SERVER_NAME"]=>
string(7) "0.0.0.0"
["SERVER_PORT"]=>
string(4) "8080"
["REQUEST_URI"]=>
string(5) "/i18n"
["REQUEST_METHOD"]=>
string(3) "GET"
["SCRIPT_NAME"]=>
string(5) "/i18n"
["SCRIPT_FILENAME"]=>
string(38) "/home/xxx/nx-i18n-storage/index.php"
["PHP_SELF"]=>
string(5) "/i18n"
["HTTP_HOST"]=>
string(12) "0.0.0.0:8080"
["HTTP_USER_AGENT"]=>
string(76) "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0"
["HTTP_ACCEPT"]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.5"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_UPGRADE_INSECURE_REQUESTS"]=>
string(1) "1"
["REQUEST_TIME_FLOAT"]=>
float(1476974974.0782)
["REQUEST_TIME"]=>
int(1476974974)
}
stop
so , i can't use i18n word ?
I have fix my issue with this : https://github.com/slimphp/Slim/issues/359#issuecomment-185519730
Overriding it by setting $_SERVER['SCRIPT_NAME'] to /index.php at the top of index.php fixes the problem ...
thank you :+1:
doesn't work but
Work !!!
i don't know why but only i18n doesn't work...
Someone can help me ?