foss42 / apidash

API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. A lightweight alternative to postman/insomnia.
https://apidash.dev
Apache License 2.0
1.37k stars 257 forks source link

Added PHP httpPlug Codegen #379

Closed apoorvdwi closed 3 months ago

apoorvdwi commented 3 months ago

PR Description

This PR adds codegen for PHP httpPlug

Related Issues

Checklist

Added/updated tests?

We encourage you to add relevant test cases.

Steps to run

I prepared a simple dockerfile that eases the running of PHP code given below

# Use the official PHP image with Apache
FROM php:7.4-apache

# Install git and unzip which might be needed for composer operations
RUN apt-get update && apt-get install -y git unzip

# Install Composer globally
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
    && php -r "unlink('composer-setup.php');"

# Set the working directory to the root of your Apache directory
WORKDIR /var/www/html

# Copy your PHP script to the Docker image
COPY . /var/www/html/

# Use Composer to install dependencies
RUN composer install

# Expose port 80 to access the Apache server
EXPOSE 80

# Start Apache in the foreground
CMD ["apache2-foreground"]
apoorvdwi commented 3 months ago

@ashitaprasad @animator please review this PR Let me know if you face any difficulties in running the code

Here is a screenshot of the code runs just in case Screenshot 2024-04-06 at 2 12 20 PM

animator commented 3 months ago

Multipart implementation is bloated and can be heavily simplified. Take a look at https://docs.php-http.org/en/latest/components/multipart-stream-builder.html

apoorvdwi commented 3 months ago

@animator let me know if any more changes are required

animator commented 3 months ago

Why are you hardcoding boundary? MultipartStreamBuilder already adds a boundary that can be obtained using

$boundary = $builder->getBoundary();

https://docs.php-http.org/en/latest/components/multipart-stream-builder.html#building-a-multipart-stream

apoorvdwi commented 3 months ago

Yes, we can use that as well or we can pass a custom boundary as well. I was using the later way. I have made the changes to use default boundary from multiparts builder

animator commented 3 months ago

Thanks for fixing the issue. LGTM 🚀