Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RewriteEngine on
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule . index.php [L]
- <?php
- use PsrHttpMessageServerRequestInterface as Request;
- use PsrHttpMessageResponseInterface as Response;
- require '../vendor/autoload.php';
- require '../src/config/db.php';
- $app = new SlimApp;
- $app->get('/hello/{name}', function (Request $request, Response $response) {
- $name = $request->getAttribute('name');
- $response->getBody()->write("Hello, $name");
- return $response;
- });
- $app->run();
- ?>
- <?php
- class db{
- // Properties
- private $dbhost = '//myip';
- private $dbuser = '//myuser';
- private $dbpass = '//mypass';
- private $dbname = '//mydbname';
- // Connect
- public function connect(){
- $mysql_connect_str = "mysql:host=$this->dbhost;dbname=$this->dbname";
- $dbConnection = new PDO($mysql_connect_str, $this->dbuser, $this->dbpass);
- $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- return $dbConnection;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment