PHP code example of ibrostudio / laravel-file-data-manager
1. Go to this page and download the library: Download ibrostudio/laravel-file-data-manager library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ibrostudio / laravel-file-data-manager example snippets
use IBroStudio\FileDataManager\FileDataManager;
$package_name = FileDataManager::load(base_path('composer.json'))
->findValue('name')
->getValue(); // = 'vendor/currentPackageName'
$package_name = FileDataManager::load(__DIR__ . '/Fixtures/Test.php')
->replaceValue('name', 'vendor/newPackageName')
->findValue('name')
->getValue(); // = 'vendor/newPackageName'
class Test
{
protected array $testArray = [
SomeClass1::class,
SomeClass2::class,
];
}
use IBroStudio\FileDataManager\FileDataManager;
$test = FileDataManager::load('Test.php');
$test
->findArray('$testArray')
->getValue(); // = ['SomeClass1::class', 'SomeClass2::class']
$test
->addArrayValue('$testArray', 'SomeClass3::class')
->write();
$test
->findArray('$testArray')
->getValue(); // = ['SomeClass1::class', 'SomeClass2::class', 'SomeClass3::class']
use Vendor\Package\Namespace\Class1;
class Test{}
use IBroStudio\FileDataManager\FileDataManager;
FileDataManager::load('Test.php')
->addRegexValue('#(use\s(.*?)\;)#s', 'use Vendor\Package\Namespace\Class2;')
->write();
$imports = FileDataManager::load('Test.php')
->findRegex('#(use\s(.*?)\;)#s')
->getValue(); // = ['use Vendor\Package\Namespace\Class1;', 'use Vendor\Package\Namespace\Class2;']
use IBroStudio\FileDataManager\FileDataManager;
FileDataManager::load('Test.php')
->replaceValue('$testValue', 'tata')
->addArrayValue('$testArray1', "'NewValue'")
->addArrayValue('$testArray2', 'OtherNewValue::class')
->addRegexValue('#(use\s(.*?)\;)#s', 'use Vendor\Package\Namespace\Class2;')
->write();