api-platform / docs

API Platform documentation
https://api-platform.com/docs/
166 stars 1.08k forks source link

[UX] New documentation hierarchy suggestion #884

Open bpolaszek opened 5 years ago

bpolaszek commented 5 years ago

Hey there,

API-Platform is an ecosystem full of features and tools, but its documentation is growing fast, and it begins to lack of an appropriate structure to keep things tidy and clear.

I have identified several drawbacks on the current documentation that could lead astray newcomers:


Read -> Install -> Configure -> Play -> Code -> Test -> Deploy -> Tune -> Hack

After thinking about this, I suggest the following key topics to drive the user from basics to advanced:

API-Platform

  1. Introduction

    State of the art, philosophy, features

  2. Installation

    On an existing project / new project / docker distribution

  3. Usage and configuration

    Schema generator, entity map, serialization, events, ...

  4. Pagination, filters and sorting

    You can start to play with your data

  5. Security

    JWT, FOSUserBundle, ACLs

  6. Exposing your API

    Versioning, deprecations, sunset, error messages, ...

  7. Consuming your API

    OpenAPI/Swagger export, GraphQL support, Client generators

  8. The Admin Component

    Big topic that should be kept handled apart

  9. Testing

    Fixtures, writing functional tests

  10. Deployment

    Kubernetes, Heroku, Platform.sh, ...

  11. Caching & performance optimization

    Cache invalidation, custom headers, Doctrine tips, PHP-PM, Blackfire

  12. Advanced Usage

    Custom operations/controllers, DTOs, custom filters, data providers/persisters, CQRS, ...

  13. How do I?

    Enable MongoDB, ElasticSearch, NelmioApiDocBundle, Mercure, file uploads, ...

  14. Troubleshooting

    Docker issues, Nginx issues, JMS serializer issues, links to SF Slack / Stackoverflow

A more detailed reorganization is available on this gist.

What do you think?

Sorry for the long post! 😅

alanpoulain commented 5 years ago

I think the aim was the contrary: having the distribution to be the common way to use API Platform and the best setup to present the examples. But your point is very good and maybe we should reconsider it. I don't think a lot of people use the distribution as is.

You're perfectly right about restructuring the documentation. API Platform is growing and the current documentation is messy: I think new developers are quickly lost and maybe some people give up their motivation for using it when they see the documentation.

(and I think GraphQL should have its own topic :stuck_out_tongue:)

bpolaszek commented 5 years ago

Hey @alanpoulain, thanks for your review.

+1 for GraphQL, maybe between The Admin Component and Testing ?

alanpoulain commented 5 years ago

IMHO before The Admin Component would be better since the admin could be compatible with GraphQL as well.

dunglas commented 5 years ago

I'm 👍 to restructure the documentation, and most ideas looks good to me but:

Also, there was a bug on the website affecting the order in the menu (the order was totally irrelevant because of this bug). It has been fixed by https://github.com/api-platform/website/pull/148 3 days ago. The order should looks more logical now 😅, but it can definitely be improved.

dunglas commented 5 years ago

I like the new TOC by the way, for the Core component.

I would suggest some changes regarding the it:

And! The "advanced" section is a very very good idea!!

dunglas commented 5 years ago

Regarding the docker-compose exec... prefix. I don't like it either. We should explain to the user how to create a bin/console alias executing docker-compose exec php bin/console under the hood the use bin/console everywhere.

alanpoulain commented 5 years ago

I don't really agree with this part:

Docker improves the experience a lot. Installing API Platform (and even Symfony) without Docker is a pain.

You're right when the user wants to try it, in a workshop or to show it, but when someone or a company wants to really use it in their project, they don't need (and don't want) to use the full framework with all this stuff in it. They want to pick what they need and it's often a composer req api. And I think we need to target these users in the documentation. That's why Symfony Flex was created: real users want to explicitly choose what they use.

Of course, I also think promoting the full ecosystem is a great thing to do, to envision all the possibilities. But we should show it off in the main page and maybe in the first part of the "Getting Started" topic but the advanced documentation should not use it.

dunglas commented 5 years ago

Not using Docker for a professional project is not an option in 2019 IMHO. And users wanting to customize everything can do it, it’s documented (but I don’t think it’s a best practice). Most users should use Docker and it’s what we must promote.

alanpoulain commented 5 years ago

Yes, but I think, most of the time, users have already their own Docker images and want to use API Platform in existing projects. Users starting from scratch by using the distribution images should not represent a lot of people (but it's hard to measure).

bpolaszek commented 5 years ago

Regarding Docker:

You're right when the user wants to try it, in a workshop or to show it, but when someone or a company wants to really use it in their project, they don't need (and don't want) to use the full framework with all this stuff in it. They want to pick what they need and it's often a composer req api. And I think we need to target these users in the documentation. That's why Symfony Flex was created: real users want to explicitly choose what they use.

Of course, I also think promoting the full ecosystem is a great thing to do, to envision all the possibilities. But we should show it off in the main page and maybe in the first part of the "Getting Started" topic but the advanced documentation should not use it.

Totally agree with @alanpoulain.

Regarding your following comment:

API Platform is a full stack framework. And is not (only) a PHP framework. JS tools will even be promoted more with the upcoming release of Admin 1.0 and the support of Next, Quasar etc in client generator. The next big milestone is OpenAPI support for those tools, to be able to use them with any API (even non-API Platform/Hydra ones). Those component must be promoted on the homepage, in the menu etc.

I understand (and share) your point, but it actually sounds confusing. JS tools are part of the stack but they're designed to work as standalones. When invoking the API-Platform name, what comes to your mind? The full-stack framework? The core? The Docker Distribution? A set of standalone components designed to work together? Maybe all this could be clarified, not at the documentation level, but at the website one (with icons, separate menus, etc). Maybe in a second time. Anyway, as they're designed to work as standalone components, I agree they deserve a 1st place in the overall documentation.

Regarding your suggested changes in the core documentation: I agree with all of them, I just have a remark about Data Provider/Data persisters: I understand it is an essential part of the core, but I definitely consider them as an advanced user concern. Understanding the core's usability is totally feasible without them, because of the great Doctrine support, but when you want to encapsulate a 3rd-party API or use Solr or any unsupported storage, you enter the "hack" section, IMO. I did not put this section as the 1st sublevel of Advanced usage because I thought that you're more likely to need DTOs or custom operations than replacing Doctrine, but I'm open to another POV.

alanpoulain commented 5 years ago

I thought that you're more likely to need DTOs or custom operations than replacing Doctrine

Using custom DataProvider/Persister is also very useful when you want to have a resource not linked to Doctrine. Typically when you need to create a "command" endpoint, for sending a mail for instance or when it impacts multiple entities and not just one. @teohhanhui has used this pattern a lot I think for the Sylius Shop API (which is not a CRUD one).

bpolaszek commented 5 years ago

@alanpoulain Interesting, I didn't think of doing this that way. Is there a public example of this? This kind of tricks would be very welcome in the new How do I? subject :-)

alanpoulain commented 5 years ago

I think @dunglas tries to explain it here: https://github.com/api-platform/docs/pull/888. You can see this pattern here (for resetting a password): https://github.com/dunglas/ShopApiPlugin/blob/api-platform/src/Command/Customer/ResetPassword.php https://github.com/dunglas/ShopApiPlugin/tree/api-platform/src/DataPersister https://github.com/dunglas/ShopApiPlugin/blob/api-platform/src/Handler/Customer/ResetPasswordHandler.php

bpolaszek commented 5 years ago

Another recurrent consistency issue:


Disabling Swagger UI

# api/config/packages/api_platform.yaml
api_platform:
    # ...
    enable_swagger_ui: false

It will switch your default documentation UI to ReDoc.

Manually Registering the Swagger UI Controller

# app/config/routes.yaml
swagger_ui:
    path: /docs
    controller: api_platform.swagger.action.ui

My suggestion:

WDYT?