Skip to content

Instantly share code, notes, and snippets.

View geggleto's full-sized avatar

Glenn Eggleton geggleto

View GitHub Profile
# eve-text-mud
## Player States:
Space
Docked
# Command List
### Space Commands
- .dock <object>
$near = "SELECT c.id, c.name, c.email, c.phone, c.logo, c.banner, c.description, cl.lat, cl.lng,
ACOS( SIN( RADIANS( cl.lat ) ) * SIN( RADIANS( '$lat' ) ) + COS( RADIANS( cl.lat ) )
* COS( RADIANS( '$lat' )) * COS( RADIANS( cl.lng ) - RADIANS( '$lng' )) ) * 6380 AS distance
FROM CLIENT_LOCATION cl
INNER JOIN CLIENT c
on cl.client_id = c.id
WHERE
ACOS( SIN( RADIANS( cl.lat ) ) * SIN( RADIANS( ? ) ) + COS( RADIANS( cl.lat ) )
* COS( RADIANS(? )) * COS( RADIANS( cl.lng ) - RADIANS( ? )) ) * 6380 < 10
ORDER BY distance ASC";
@geggleto
geggleto / index.php
Created January 26, 2016 22:29
slim 3 gist 7
<?php
$app->add(function ($req, $res, $next) {
//DO SOMETHING BEFORE THE REQUEST IS PROCESSED
$res = $next($req, $res); //PROCESS THE REQUEST
//DO SOMETHING AFTER THE REQUEST HAS BEEN PROCESSED
if ($res->getStatusCode() > 500) {
//Do something with a server error, maybe email someone or submit a bug report
}
@geggleto
geggleto / index.php
Created January 26, 2016 22:21
Slim gist 6
<?php
$myPOST = $request->getParsedBody();
@geggleto
geggleto / index.php
Created January 26, 2016 22:20
slim 3 gist 5
<?php
$myGET = $request->getQueryParams();
@geggleto
geggleto / index.php
Created January 26, 2016 22:12
slim 3 gist 4
//Let's use it!
$app->get('/hello[/[{name}]]', function ($req, $res, $args) {
if (!empty($args['name'])) {
return $this->view->render($res, "hello.twig", ["name" => $args['name']]);
} else {
return $this->view->render($res, "hello.twig", ["name" => ""]);
}
});
$app->run();
@geggleto
geggleto / index.php
Created January 26, 2016 21:00
slim 3 gist 3
$app->get('/hello[/[{name}]]', function ($req, $res, $args) {
$get = $req->getQueryParams(); // Grab the Query Params... ["test" => "true"]
if (!empty($args['name'])) {
return $this->view->render($res, "hello.twig", ["name" => $args['name'], "test" => $get['test']]);
} else {
return $this->view->render($res, "hello.twig", ["name" => "", "test" => $get['test']]);
}
});
@geggleto
geggleto / index.php
Last active January 26, 2016 22:12
slim 3 gist 2
//Let's configure it.
// Fetch DI Container
$container = $app->getContainer();
// Register Twig View helper and configure it
$container['view'] = function ($c) {
//You can change this as you want
$view = new \Slim\Views\Twig('templates', [
'cache' => false //or specify a cache directory
]);
@geggleto
geggleto / index.php
Created January 26, 2016 20:56
slim 3 gist 1
$app->get('/hello[/[{name}]]', function ($req, $res, $args) {
if (!empty($args['name'])) {
return $res->write("Why Hello " . $args['name']);
} else {
return $res->write("Hello!");
}
});
## Use case
I have several "components" which are standalone Slim applications.
Maybe its a "UserManagement"... while I can run this module at /users on it's own... I want to install this package on another larger project.
In my main app,
I load "components"...
$components = [
"UserManagement" => [
"routes" => "../usermanagement/routes.php",