- Saved searches
- Use saved searches to filter your results more quickly
- ajthinking/archetype
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- readme.md
- Saved searches
- Use saved searches to filter your results more quickly
- License
- pheditor/pheditor
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Create, Edit And Delete File Using PHP And HTML
- To Create, Edit And Delete File It Takes Only Two Steps:-
- Step 1. Make a HTML file and define markup
- Step 2. Make a PHP file to create, edit and delete file
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Edit PHP files programmatically
ajthinking/archetype
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
readme.md
Enabling Rapid-Application-Development-tools, PR-bots, code analyzers and other things
- Programatically modify php files with an intuitive top level read/write API
- Read/write on classes, framework- and language constructs using FileQueryBuilders and AbstractSyntaxTreeQueryBuilders
composer require ajthinking/archetype
That’s it! Check out introduction of concepts below or review the API examples
use Archetype\Facades\PHPFile; // Create new files PHPFile::make()->class(\Acme\Product::class) ->use('Shippable') ->public()->property('stock', -1) ->save();
// Modify existing files PHPFile::load(\App\Models\User::class) ->className('NewClassName') ->save();
LaravelFile read/write API
use Archetype\Facades\LaravelFile; // extends PHPFile // Expanding on our User model LaravelFile::user() ->add()->use(['App\Traits\Dumpable', 'App\Contracts\PlayerInterface']) ->add()->implements('PlayerInterface') ->table('gdpr_users') ->add()->fillable('nickname') ->remove()->hidden() ->empty()->casts() ->hasMany('App\Game') ->belongsTo('App\Guild') ->save() ->render();
namespace App\Models; use App\Contracts\PlayerInterface; use App\Traits\Dumpable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable implements PlayerInterface < use HasApiTokens, HasFactory, Notifiable; protected $table = 'gdpr_users'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'nickname', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = []; /** * Get the associated Guild */ public function guild() < return $this->belongsTo(Guild::class); > /** * Get the associated Games */ public function games() < return $this->hasMany(Game::class); > >
Filter and retrieve a set of files to interact with.
// find files with the query builder PHPFile::in('database/migrations') ->where('extends', 'Migration') ->andWhere('className', 'like', 'Create') ->get() // returns Collection of PHPFiles // Quickly find the Laravel User file $file = LaravelFile::user(); // Quickly find Laravel specific files LaravelFile::models()->get(); LaravelFile::controllers()->get(); LaravelFile::serviceProviders()->get(); // .
Abstract Syntax Tree QueryBuilder
As seen in the previous examples we can query and manipulate nodes with simple or primitive values, such as strings and arrays. However, if we want to perform custom or more in dept queries we must use the ASTQueryBuilder .
Example: how can we fetch explicit column names in a migration file?
LaravelFile::load('database/migrations/2014_10_12_000000_create_users_table.php') ->astQuery() // get a ASTQueryBuilder ->classMethod() ->where('name->name', 'up') ->staticCall() ->where('class', 'Schema') ->where('name->name', 'create') ->args ->closure() ->stmts ->methodCall() ->where('var->name', 'table') ->args ->value ->value ->get();
The ASTQueryBuilder examines all possible paths and automatically terminates those that cant complete the query:
The ASTQueryBuilder relies entirely on nikic/php-parser. Available query methods mirror the PhpParser types and properties. To understand this syntax better you may want to tinker with dd($file->ast()) while building your queries. Basic conventions are listed below.
- Traverse into nodes by using methods ( method() , staticCall() . )
- Traverse into node properties by accessing properties ( args , stmts . )
- Filter results with where(. )
- Resolving matching paths with get()
ASTQueryBuilder also supports removing, replacing and injecting nodes 🔧
// Replace a node property $file->astQuery() ->class() ->name ->replaceProperty('name', $newClassName) ->commit() // updates the file's AST ->end() // exit query ->save()
If a file can’t be parsed, a FileParseError will be thrown. This can happen if you try to explicitly load a broken file but also when performing queries matching one or more problematic files.
To see all offending files run php artisan archetype:errors . To ignore files with problems, put them in config/archetype.php -> ignored_paths .
php artisan vendor:publish --provider="Archetype\ServiceProvider"
PRs and issues are welcome 🙏 Feel free to take a stab at an incomplete test.
git clone git@github.com:ajthinking/archetype.git cd archetype composer install ./vendor/bin/pest
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
License
pheditor/pheditor
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Pheditor is a single-file editor and file manager written in PHP.
- Editor with syntax highlighting
- File Manager (create, rename and delete files and directories)
- Password protected area
- Keeping the history of edited files and changes
- Keyboard shortcuts
- Access levels for reading and writing and other permissions
- Terminal
- Dark mode
- Search in files
Install using composer: composer create-project pheditor/pheditor
or just upload pheditor.php to your web host (and/or rename it as you wish).
By default Pheditor uses CDN to load required libraries but also it is possible to load assets from local directory.
For using local assets follow these steps:
- The default password is admin . Please change the password after install or first login.
- As the script gives permission to edit files, it is recommended to keep the address secret or protected depending on the web-server you are using.
Optional settings:
The settings would be editable in the main PHP file (pheditor.php by default). The settings are as below:
- Define patterns for files and directories to view/edit (empty means all files & directories)
- Log file path
- Show/Hide hidden files
- Limit access to the page only for an IP address (empty means access for all)
- Show/Hide main pheditor file (pheditor.php) in files list to edit
- History files path
- Word wrap
- Changing main directory ( MAIN_DIR )
- Enable/Disable Terminal
- Define allowed terminal commands
- Change editor theme ( EDITOR_THEME ) (theme list)
- New file and directory permissions ( DEFAULT_DIR_PERMISSION and DEFAULT_FILE_PERMISSION )
Using without password:
You can empty the PASSWORD constant in the source code to access the script without the password. But it is highly recommended to use it and change the default password after installation.
Access Levels and Permissions:
There are eight permissions for users that is defined in PERMISSIONS constant. You can remove any of them as you need.
Default value: newfile,newdir,editfile,deletefile,deletedir,renamefile,renamedir,changepassword,uploadfile,terminal
If you found this project useful, please consider making a donation to keep this project alive.
Cryptocurrency | Address |
---|---|
Bitcoin | bc1qqjm32eupk7lw3kctlmflqh9spzalya9mqwppw9 |
Ethereum | 0x3d7324f1718fF9f9F57b1d45c80dEdea59F0b412 |
Create, Edit And Delete File Using PHP And HTML
In this tutorial we will show you how to create, edit and delete file using PHP and HTML. By using these methods you can create any type of file, edit any file and delete any file.
To Create, Edit And Delete File It Takes Only Two Steps:-
Step 1. Make a HTML file and define markup
We make a HTML file and save it with a name file.html
In this step we create three forms to create, edit and delete file. In first form user have to enter file name to create new file.
In second form user have to enter file name and text to add in that file.In third form user have to enter file name to delete that file.You may also like delete multiple records from MySQL using PHP.
Step 2. Make a PHP file to create, edit and delete file
We make a PHP file and save it with a name file_operation.php
if(isset($_POST['edit_file'])) < $file_name=$_POST['file_name']; $write_text=$_POST['edit_text']; $folder="files/"; $ext=".txt"; $file_name=$folder."".$file_name."".$ext; $edit_file = fopen($file_name, 'w'); fwrite($edit_file, $write_text); fclose($edit_file); >if(isset($_POST['delete_file'])) < $file_name=$_POST['file_name']; $folder="files/"; $ext=".txt"; $file_name=$folder."".$file_name."".$ext; unlink($file_name); >?>
In this step we create three isset() function to do three different file operations like create a file, edit existing file and delete a file.
In first isset() function we get file name entered by the user to create file with that name we specify ‘.txt’ file extension you can specify any extension or you can ask from user also then we use fopen function to create file and then using fclose function to close that file.
See fopen is used for both purposes creating and editing a file.
In third isset() function we get file name to delete entered by the user then we use unlink function to delete that file from folder.
Thats all, this is how to create, edit and delete file using PHP and HTML. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.