Nicotine

Open source framework for PHP & MySQL

Downloads Page

Working with API Requests

Create a file like get-products.php inside /workspace/api/ folder. Place a piece of code inside this newly created file, like:

<?php
declare(strict_types=1);

namespace 
workspace\api;

use 
nicotine\Registry;

// You may need database instance.
$db Registry::get('Database');

// You may need Proxy instance.
$proxy Registry::get('Proxy');

// Using Database instance.
$result $db->getAll("SELECT `name`, `email` from `test`");
d(json_encode($result));

// Using Proxy instance for a Site side model.
$result $proxy->site->model('ProductModel')->getProducts();
d(json_encode($result));

Now access the URL /api/get-products.html. If your configuration does't use URL suffix, remove .html extension from URL.

API error logs files are stored per day, inside /workspace/api/logs/. You can delete the content of that folder, once they are resolved, but I not recommend to delete .keep file. It tells Git to keep that folder. However, log files are gitignored.