A Quick Tutorial - machitgarha/JsonFile GitHub Wiki
This tutorial will help you to understand the basics of the JSONFile class and how to work with.
Creating an instance is the first step. Consider we want to open composer.json
file in the current directory:
// Requiring the autoload here
// require __DIR__ . "/vendor/autoload.php";
use MAChitgarha\Component\JSONFile;
$jsonFile = new JSONFile(__DIR__ . "/composer.json");
Good, everything is ready. You can now make operations. For more information, see the JSON
's GitHub wiki here.
For example, let's change the name and type of our app:
$jsonFile->set("name", "you/cool-app");
$jsonFile->set("type", "special-type");
OK, we're in the last step, saving the file:
$jsonFile->save();
Done! You have updated your composer.json
file in your app. You can do a lot more with JSONFile class.