Skip to content

Commit b35068e

Browse files
authored
Merge pull request #637 from Jacopo-Felluga/update-docs-run-code-php
Updated documentation: How to run API Dash code in PHP (cURL)
2 parents 1618b6c + a84d746 commit b35068e

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

Diff for: doc/user_guide/instructions_to_run_generated_code.md

+82-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,88 @@ java -jar api_test.jar
740740

741741
## PHP (curl)
742742

743-
TODO
743+
Here are the detailed instructions for running the generated API Dash code in PHP (using `curl`) for macOS, Windows, and Linux:
744+
745+
### 1. Install and set PHP:
746+
Before starting out, we need to install PHP in our system.
747+
#### macOS:
748+
- Go to the official PHP website: [https://www.php.net/manual/en/install.macosx.php](https://www.php.net/manual/en/install.macosx.php)
749+
- Follow the installation instructions.
750+
751+
#### Windows:
752+
- Go to the official PHP website: [https://www.php.net/manual/en/install.windows.php](https://www.php.net/manual/en/install.windows.php)
753+
- Follow the installation instructions.
754+
755+
#### Linux:
756+
The installation process depends on your Linux distribution. Use the appropriate command below:
757+
- ##### Ubuntu/Debian
758+
```bash
759+
sudo apt update
760+
sudo apt install php php-cli php-curl php-mbstring php-xml php-zip -y
761+
```
762+
- ##### Arch Linux / Manjaro
763+
```bash
764+
sudo pacman -S php php-apache php-cgi php-curl php-mbstring php-xml php-zip
765+
```
766+
- ##### Fedora / CentOS
767+
```bash
768+
- sudo dnf install php php-cli php-curl php-mbstring php-xml php-zip -y
769+
```
770+
- ##### OpenSUSE
771+
```bash
772+
sudo zypper install php php-cli php-curl php-mbstring php-xml php-zip
773+
```
774+
775+
✅ Finally, check that everything works correctly pasting this command in your terminal
776+
```bash
777+
php --version
778+
```
779+
780+
### 2. Check cURL
781+
cURL is usually enabled by default. To check if it's active, run:
782+
```bash
783+
php -m | grep curl
784+
```
785+
and check if it returns **curl** as output
786+
787+
#### If curl is disabled
788+
789+
1. Open the `php.ini` configuration file. You can find its location by running:
790+
```bash
791+
php --ini
792+
```
793+
2. Open the file in a text editor/IDE
794+
3. Find this line
795+
```bash
796+
;extension=curl
797+
```
798+
4. Remove the semicolon (`;`) at the beginning to enable it:
799+
```bash
800+
extension=curl
801+
```
802+
5. Save and restart php by using
803+
```bash
804+
sudo systemctl restart apache2 # For Apache
805+
sudo systemctl restart php8.2-fpm # For PHP-FPM (Nginx)
806+
```
807+
808+
### 3. Execute the generated code:
809+
Once you have everything needed installed, follow these steps to execute the generated code:
810+
811+
1. **Open a IDE/text editor** ✍️ (Visual Studio, VS Code or any other text editor).
812+
2. **Create a php file ( ex. `request.php` )** ✍️ (Visual Studio, VS Code or any other text editor).
813+
3. **Copy and paste the generated API code** 📋 from API Dash into the `request.php` file.
814+
815+
#### In Visual Studio:
816+
1. Click the **Start Debugging `(F5)`** button from the top menu to run the project.
817+
2. The terminal will display the API response.
818+
819+
#### Using the CLI:
820+
1. Open the terminal at the project root directory and run the file you've created:
821+
```bash
822+
php filename.php
823+
```
824+
2. The terminal will display the API response.
744825

745826
## PHP (guzzle)
746827

0 commit comments

Comments
 (0)