john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Nginx static files slim php require import class

vi /etc/nginx/sites-available/default

server { server_name localhost; root /var/www; index index.php;

    # serve static files
    location ~ ^/(images|javascript|js|css|flash|media|static)/  {
    root    /var/www;
    expires 30d;
    }

    location ~ \.php$ {
            try_files $uri $uri/ /index.php?$args =404;
            fastcgi_pass unix:/var/run/php5-fpm.socket;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
    }

}

http://localhost/static/test.css or css/test.css


vi /var/www/composer.json { "require": { "slim/slim": "2.*", "hipchat/hipchat-php": ">=1.0.0" } }

php composer.phar update

vi /var/www/index.php <?php require 'vendor/autoload.php';

$app = new \Slim\Slim(); // $app = new \Slim\Slim( array(     'debug' => true  ) );


$app->get( '/', function(){
    echo "<html><body>";
    echo dirname( __FILE__ ) . " <br />\n";
    $token = 'your-token-here';
    $hc = new HipChat\HipChat( $token );
    echo $hc::DEFAULT_TARGET;

    foreach( $hc->get_rooms() as $room ){
        echo " - $room->room_id = $room->name\n";
    }

    echo "</body></html>";
} );

$app->run();

?>


  • « Nginx php fpm composer dependency slim framework
  • http server request parse query and body parameters »

Published

Jun 4, 2013

Category

linux

~87 words

Tags

  • class 4
  • files 16
  • import 12
  • installs 41
  • nginx 7
  • php 82
  • require 3
  • slim 3
  • static 4