artiframe remove

The artiframe remove command safely deletes a file in your project. Going far beyond a simple file deletion; it automatically detects the file type (View, Class, API), finds linked asset files, scans for class usages across the project, and minimizes the risk of data loss by asking for confirmation at each step.

Usage

$ artiframe remove [file-path] [flags]
FlagDescription
--force / -yBypasses confirmation prompts and automatically accepts all steps.
--no-assetsWhen deleting a View, it prevents the deletion of its associated CSS/JS files.
--force-classForces the deletion of a class even if it is currently being used in API files.

Smart File Detection

The system determines which deletion mode to engage by inspecting the target file path:

1. View Deletion (pages inside the public/ directory)

When you attempt to delete a page created with make:view, the system parses the page's source code. It scans the href and src attributes to detect linked CSS and JS files, and asks if you want to delete them as well.

$ artiframe remove public/panel/reports

⚠️  public/panel/reports.php will be deleted. Do you confirm? [y/N]: y

⚠️  Should the associated asset files be deleted as well?
    - public/assets/css/panel/reports.css
    - public/assets/js/panel/reports.js
    [y/N]: y

  ✅ Deleted: .../public/assets/css/panel/reports.css
  ✅ Deleted: .../public/assets/js/panel/reports.js

✅ public/panel/reports.php has been deleted.

2. Class Deletion (src/ or app/ directories)

If you attempt to delete a class file, the system recursively scans all API files under public/api/ to check if there are any references (imports, calls) to this class. If usage is detected, it pinpoints the exact file and lines where it is being used.

$ artiframe remove src/Service/PaymentService

🚨 PaymentService class is currently being used in the following API files:
   -> /var/www/project/public/api/standart/payment/charge.php (Lines: 4, 17)

📌 It is recommended to update the related API files before deleting this class.

❓ Do you still want to delete it? [y/N]: y

✅ src/Service/PaymentService.php has been deleted.

Security: Path Traversal Protection

If the target file points to a location outside the project's root directory (e.g., an attack attempt like ../../etc/passwd), the real path is resolved via realpath(). If it falls outside the project boundaries, the operation is immediately aborted:

❌ Security violation: Target file is outside the project directory!

Extensionless Usage

The .php extension is optional. The system first searches for the exact path provided, and if not found, it appends .php and tries again. You can use both relative (relative to the project root) and absolute paths.