In this post, I would like to show you creating a JSON file and appending content to it whenever somebody submits a form. For this tutorial, I am gonna use Laravel 5.6 version.
Let’s create a brand new Laravel project via Composer Create-Project command. lets issue following command from your terminal:
It will create a directory called
jsonAppendDemo and download all the Laravel project files and its dependencies.
After completing setup process, create a view file called
resources/views directory with following
Create a controller called
ContactController.php with below command:
After creating controller lets define following methods,
index is to show the contact form and
store method is to handle the submitted data.
All set lets define routes to access the form and to process the submitted data in your
web.php route file.
Now start the php server with below command
Once it is started, if you visiting http://localhost:8000, you should see the following page in your browser
Once you submit the form data will be stored in the
Here is my
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.