Skip to content

Conversation

@lonnieezell
Copy link
Member

Description
This creates a new "Getting Started with RESTful APIs" guide that steps through using the auto-routing and ResponseTrait, plus the new transformers and API response pagination to create a simple API.

It moves the existing tutorial under a new "Guides" section.

@lonnieezell lonnieezell changed the title Created a new Make an RESTful API guide docs: Created a new Make an RESTful API guide Nov 21, 2025
Copy link
Contributor

@neznaika0 neznaika0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guides are a great idea. We can discuss on the forum what built-in mechanics are possible using the framework. I tried to tell you about the Validator, but you didn't approve.

I looked it up from phone.


.. code-block:: console

php spark make:controller Api/Books
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Book or Books? You use a different naming convention below the text.
It is recommended to name endpoints in the plural /books/123


class BookModel extends Model
{
protected string $table = 'books';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many people recommend naming tables in the singular: book, author

I can't check everything, but could it affect the internal automation? Is there a dependence on the ending "s"?

This creates a new file under ``app/Database/Migrations/``.

Edit the CreateAuthorsTable file to look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file here is ``CreateAuthorsTable.php`` For visual perception.


Each author simply has a name for our purposes. We have made the name a uncommented unique key to prevent duplicates.

Now edit the CreateBooksTable file to look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file here is ``CreateBooksTable.php`` For visual perception.


The "Improved" auto router is more secure and reliable than the legacy version, so it's recommended for all new projects.

Then, in ``app/Config/Routing.php`` confirm auto routing is **on**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On? Maybe "enabled"?

Getting Started with REST APIs
##############################

.. content::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo .. contents::

@neznaika0
Copy link
Contributor

You have moved the pages to the directory. Some error correction paths need to be updated.
../outgoing/* >> ../../outgoing/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants