mostly google translate api in paid version but You can do this in two way first install packages for google translate or include google translate class file .
install packages
php-google-translate-free Package
phpProject is my folder run this command
- composer require statickidz/php-google-translate-free
Use the class file of google translate.
- Go to your project folder and create a class file named with google_translate.class.php
- Copy this code and paste in your google_translate.class.php
for more information check out this link and get your solution ShortTutorials