80 likes | 103 Views
Symfony can be used to create an ecommerce app. You can also easily integrate ReactJS on the front-end of your <a href="https://www.cloudways.com/blog/build-symfony-ecommerce-app/">Symfony ecommerce</a> app and use Cloudinary for storing images.
E N D
Create an Ecommerce App in Symfony Using React and Cloudinary
Prequisites • Knowledge of React, OOP with PHP, and MVC Web API Patterns • Cloudinary Account • Node.js • Yarn Package Manager • Symfony Installed and Optimized on the server/localhost
CreateProducts in Symfony • Create Symfony API manually by generating doctrine entity • Generate and configure product entity • Create and Configure Product Controller. Add index() method in the controller • Create new product endpoints by adding a function inside index() method. Here you are creating products. • You will be using two custom functions in the code: uploadImageToCloudinary() and updateDatabase() • First one uploads image to Cloudinary and second one will persist and flush data.
ListAll Products • Create a function to fetch and list all the products. • The function will return a JSON response to list the products. • The JSON response will be looped through React so it is displayed correctly to the users. • This will be done in Product Controller created earlier. • Inside the Product Controller, there is ProductRepository which will be created later. • Inside index(), add a constructor method and the mentioned private properties.
Adding Favorite Count to the Product • For this, a Favorite button will be added to the front-end. • To record the number for favorites received, we will create API. • For this, a method will be added to ProductController.
Setting Up and Configuring Cloudinary • Login to your Cloudinary Dashboard and note down your Cloud name, API Key and API Secret. • Use PHP-SDK provided by Cloudinary to create upload service. • Install Cloudinary and create a folder name Service inside srcfolder. • Create file named imageUploader.php under the folder. • In this file, define a PHP class for image uploading on Cloudinary. • Open .env file and update your Cloudinary credentials in it.
Read the full article on Creating Symfony Ecommerce app with Cloudinary and React.