Download the PHP package jetwaves/edit-array-in-file without Composer
On this page you can find all versions of the php package jetwaves/edit-array-in-file. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jetwaves/edit-array-in-file
More information about jetwaves/edit-array-in-file
Files in jetwaves/edit-array-in-file
Package edit-array-in-file
Short Description CRUD (Add, modify, list, delete) of elements from arrays in php file.
License MIT
Informations about the package edit-array-in-file
edit-array-in-file
CRUD (create/add/insert, modify/update, list/find/search, delete/remove) of elements from arrays in php file.
CREDIT TO dingo/api and Laravel framework
Idea: use ORM-like code to manipulate file content
How to use:
Installation: (eg. in a Laravel 5+ project)
API:
- $editor->where($arrayName, $options = [], $type = self::TYPE_VARIABLE) : Find the code snippet(an array)
- $editor->find($keyword, $comp = null, $type = self::FIND_TYPE_KEY_ONLY) : Find a line in the array above
- $editor->insert($data, $insertType = self::INSERT_TYPE_RAW ) : Insert a new line into the array
- $editor->delete() : Delete the line found by find()
- $editor->save() : Reconstruct the file lines in memory
- $editor->flush() : Write the edited file content into file
Example:
include the lib:
or
When the target is an array in the value of a Key-Value pair)
1.1.CRUD->R : Find target key in a php source code file:
the result is:
1.2.CRUD->C : Insert into target key's value in a php source code file:
the result is : (content of file app.php)
1.3. CRUD->R : Search in target variable for a key :
the result is :
1.4. CRUD->D : delete one line in target Key-Value pair
It will delete the line 'JWTAuth' from file Kernel.php
When the target is an array in a variable)
2.1.CRUD->R : Find target variable in a php source code file:
the result is:
2.2.CRUD->C : Insert into target key's value in a php source code file:
the result is : (content of file Kernel.php)
2.3. CRUD->R : Search in target variable for a key :
the result is :
2.4. CRUD->D : delete one line in target variable
It will delete the line 'auth.basic' from file Kernel.php