Developing an app
Edit on GitHubTo develop an app, follow the instructions in this document.
Prerequisites
- You have completed the thought process for your app.
- You have installed the Spryker SDK.
- You have an empty GitHub repository.
- You have a local project directory where you want to work, for example,
/www/my-app
.
Thought process
First, think about what your app should be capable of: what features it will bring, and what data will be exchanged, not only to you but also to those interested in your app functionality. For example, what messages could be of interest to others, and what API endpoints you should provide.
API-first
It’s strongly recommended that apps follow the API-first approach. API-first means that your app is centered on the API. It should be possible to perform every action via the scripting language, and every piece of functionality should be available for other systems to leverage. For more information on the API-first approach, see this blog post. You need to have a clear understanding of what your app API will provide to others, and always keep that in mind when designing your app.
Schema-first
Before you start with the development, you should design your API schema files. Depending on your requirements, you can have an OpenAPI or an Async API schema file. In this step, you define the Sync API endpoints your app will provide to others, the messages you will emit or consume, and the data you expect to work with.
For more information about Async API schema design, see Designing your APIs with Async API.
For more information about OpenAPI schema design, see Best practices in API design.
You can use the following tools to design your APIs:
You can also use wizards provided by Spryker, which will be used by the SprykerSDK workflow.
Build an app
You can build a new app with the help of the SprykerSDK. After you have installed the Spryker SDK, you can run the following commands to start building the app.
- Ensure that you are in the correct working directory:
cd /www/my-app (The local project directory you created before)
- Initialize the project:
spryker-sdk sdk:init:project --workflow=app
- Run the workflow:
spryker-sdk sdk:workflow:run
You can skip through the prompts by hitting Enter.
Starting from SprykerSDK version 0.3.0, you can use the following set of commands:
cd /www/my-app (The local project directory you created before)
spryker-sdk sdk:workflow:run # and select the app workflow
The workflow guides you as much as possible through the process of building an app. Whenever something needs manual interaction, the workflow stops with a message on what you need to do. After you completed the manual step, re-run the workflow with the spryker-sdk sdk:workflow:run
command. This continues the previously paused workflow.
Workflow details
The spryker-sdk sdk:workflow:run
command guides you through the whole process of building an app. This command does the following.
1. Downloads the boilerplate code and adds app definition files
One of the first steps of the workflow is downloading a reduced Spryker project into the working directory. It already contains a lot of code that lets you start implementing your business logic. This step can take a few minutes to complete.
At this point, no dependencies are installed.
There are a couple of files that an app must have. The workflow guides you through creating them.
Manifest files
The manifest files define the details like title, category, and description of the app. The manifest files are also used to display information about the app on the App Catalog Page and the App Detail Page in the Back office.
For more details on the manifest files, see App manifest.
You need to update the manifest file manually. The SDK only creates a boilerplate file.
Configuration file
The configuration file defines the form that is displayed in the Back Office App Catalog after the App was connected and needed some configuration.
This file is created with the help of a wizard, but you can also add or update it manually.
For more details, see App Configuration.
Translation file
The translation file contains the keys and the translation values for each locale in which the app should be displayed.
This file is created with the help of a wizard, but you can also add or update it manually.
For more details, see App Configuration Translation.
2. Creates app API
The command defines Sync API and Async API.
Sync API
The Sync API defines the app’s synchronous endpoints, or Glue endpoints. The workflow creates a boilerplate that you need to update with the required endpoints your app should have. See the current OpenAPI specification.
For more details about the Sync API with information specific to Spryker, see Sync API.
Async API
The Async API defines the app’s asynchronous endpoints, also known as events and messaging. The workflow creates a boilerplate one that you need to update with the required endpoints your app should have. See the current Async API specification.
For more details about the Async API with information specific to Spryker, see Async API.
3. Runs code generators
After the previous steps were executed and you updated the API schema files to your needs, the code generators are executed. The code generators load the schema files and create as much code, including tests, as possible.
Review the generated code carefully.
4. Performs validation
The workflow executes some validations during the process. The workflow stops when some validations fail and displays a message that helps you to fix the issues.
What’s next
With the executed workflow, you can develop with the code as you’re used to developing Spryker applications.
Thank you!
For submitting the form