Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'bk' of github.uconn.edu:dmd-web-and-mobile/foodbank int…
…o bk
  • Loading branch information
briankelleher committed Nov 22, 2016
2 parents 32a21b5 + 5002fc2 commit 00ec423
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.php]
indent_style = tab
indent_size = 2
13 changes: 7 additions & 6 deletions api/index.php
@@ -1,16 +1,17 @@
<?php

// use \Psr\Http\Message\ServerRequestInterface as Request;
// use \Psr\Http\Message\ResponseInterface as Response;
$autoloader = require './vendor/autoload.php';
$autoloader->add('', __DIR__ . '/generated-classes/');
require './generated-conf/config.php';
$autoloader = require './vendor/autoload.php'; // Composer Autoload Libraries
$autoloader->add('', __DIR__ . '/generated-classes/'); // Propel ORM Classes
require './generated-conf/config.php'; // Propel Config
require './config.php'; // Slim Config

$app = new \Slim\App();
// Init Slim
$app = new \Slim\App($config);

/**
* Routes
*/
require './routes/category.php';

// Run App
$app->run();
8 changes: 6 additions & 2 deletions api/routes/category.php
@@ -1,5 +1,9 @@
<?php

/**
* GET All Categories
* No Parameters
*/
$app->get('/category/all', function( $request, $response ) {
$q = new CategoryQuery;
$cats = $q::create()->find();
Expand All @@ -11,10 +15,10 @@ $app->get('/category/all', function( $request, $response ) {
"data" => []
];
foreach( $cats as $cat ) {
$response_json["data"][] = array(
$response_json["data"][] = [
"id" => $cat->getId(),
"name" => $cat->getName()
);
];
}
$response = $response->withJSON($response_json);
return $response;
Expand Down

0 comments on commit 00ec423

Please sign in to comment.