{"id":20935533,"url":"https://github.com/eypsilon/get-used","last_synced_at":"2026-05-07T00:35:19.349Z","repository":{"id":57896645,"uuid":"526888856","full_name":"eypsilon/get-used","owner":"eypsilon","description":"Namespace helper - create \"use\" statements with names of Classes, Functions and Constants used in a Script.","archived":false,"fork":false,"pushed_at":"2025-04-19T23:10:13.000Z","size":1306,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T07:10:57.723Z","etag":null,"topics":["namespace","namespaces","php","php-console","php-use","phpgui","terminal"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eypsilon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-20T10:03:05.000Z","updated_at":"2025-04-19T23:10:16.000Z","dependencies_parsed_at":"2025-07-25T03:28:27.864Z","dependency_job_id":"2d40795c-d1c6-4438-88f9-4cfd5c09d657","html_url":"https://github.com/eypsilon/get-used","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/eypsilon/get-used","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2Fget-used","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2Fget-used/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2Fget-used/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2Fget-used/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eypsilon","download_url":"https://codeload.github.com/eypsilon/get-used/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eypsilon%2Fget-used/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273090214,"owners_count":25043931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["namespace","namespaces","php","php-console","php-use","phpgui","terminal"],"created_at":"2024-11-18T22:15:28.167Z","updated_at":"2026-05-07T00:35:19.323Z","avatar_url":"https://github.com/eypsilon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GetUsed - PHP Namespace Import Generator\n\nGetUsed is a powerful tool that automatically generates PHP `use` statements for your code. It scans your PHP files to detect all classes, functions, and constants being used, then creates properly formatted import statements ready to paste at the top of your file.\n\n## Why Use This Tool?\n\n### 1. Clean, Readable Code\nInstead of using fully qualified names with backslashes (`\\Exception`, `\\json_encode()`), proper imports make your code cleaner and more readable.\n\n### 2. Prevent Errors\nMissing backslashes in namespaced code can cause hard-to-debug errors. Using proper imports eliminates this risk entirely.\n\n### 3. Save Time\nManually tracking and writing imports is tedious. GetUsed generates them all in seconds with a single command.\n\n### 4. IDE Integration\nWith the included VSCode integration, you can generate imports with a keyboard shortcut (Ctrl+Shift+T).\n\n### 5. Maintainability\nIf a class moves to a different namespace, you only need to update the import statement, not every occurrence in your code.\n\n## How It Works\n\nGetUsed analyzes your PHP code to:\n- Detect classes, interfaces, and traits being used\n- Find function calls that could benefit from imports\n- Identify constants referenced in your code\n- Generate properly formatted `use` statements\n- Comment out imports that already exist in your file\n\n__VSCode Screenshot__\n\n![Visual Studio Code Example Response](/www/used/assets/screenshot-vscode.png)\n\n## Technical Background\n\nThe `use` statement in PHP allows you to import classes, functions, and constants from other namespaces. For example, if you call `json_encode()` within a namespaced class, PHP first searches in the current namespace before falling back to the global namespace.\n\nYou can use backslashes like `\\json_encode()` to reference the global namespace directly, but this makes code less readable. A better approach is to import what you need at the top of your file:\n\n```php\n// Import a class\nuse DateTime;\n\n// Import a function\nuse function json_encode;\n\n// Import a constant\nuse const PHP_EOL;\n\n// Import with an alias\nuse function MyNamespace\\myJsonEncoder as json_encode;\n```\n\nGetUsed automates this process by analyzing your code and generating all necessary import statements.\n\n## Installation\n\n```sh\n# create directory if not exist\nmkdir -p ~/bin/many\n\n# enter directory\ncd ~/bin/many\n\n# clone GetUsed\ngit clone https://github.com/eypsilon/get-used.git\n\n# make it executable\nchmod -v 770 ~/bin/many/get-used/GetUsed.php\n```\n\n## Usage\n\n### From Terminal\n\n```sh\n~/bin/many/get-used/GetUsed.php /path/to/src/AnyClass.php\n```\n\n### Via Web Interface\n\n```sh\ncd ~/bin/many/get-used/www/used\nphp -S localhost:8000\n```\n\nThen open [localhost:8000](http://localhost:8000) in your browser.\n\n### Set an Alias (recommended)\n\n```sh\n# Edit your bash aliases\n~$ sudo gedit ~/.bash_aliases\n\n# Add this line\nalias GetUsed='~/bin/many/get-used/GetUsed.php'\n\n# Refresh aliases\n~$ source ~/.bash_aliases\n```\n\nNow you can simply use:\n```sh\nGetUsed /path/to/src/AnyClass.php\n\n# Get help\nGetUsed -h\n```\n\n### VSCode Integration\n\nAdd this to your `~/.config/Code/User/keybindings.json`:\n\n```json\n{\n    \"key\": \"ctrl+shift+t\",\n    \"command\": \"workbench.action.terminal.sendSequence\",\n    \"args\": { \"text\": \"GetUsed ${file}\\u000D\" }\n}\n```\n\nNow you can press Ctrl+Shift+T on any open PHP file to generate import statements instantly.\n\n## Example Output\n\n```php\n// file = /path/to/src/Http/Curler.php\n// start = 1661266197.6779\n// end = 1661266197.7762\n\n/** defined(0), taken(0), constant(2), class(2), function(2), total(6) */\n\nuse DateTime;\nuse DateTimeZone;\nuse function array_keys;\nuse function array_merge;\nuse const PHP_EOL;\nuse const JSON_UNESCAPED_SLASHES;\n```\n\nIf imports already exist in your file, GetUsed will comment them out to avoid duplicates.\n\n## Screenshots\n\n__Web Interface__\n\n![Web Interface Example Response](/www/used/assets/screenshot-sw.png)\n\n__Terminal Output__\n\n![Terminal Example Response](/www/used/assets/screenshot-sw-terminal-out.png)\n\n## Authors\n\n- Original tool by [Engin Ypsilon](https://github.com/eypsilon)\n- README editted by [Claude](https://www.anthropic.com/claude), Anthropic's AI assistant\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feypsilon%2Fget-used","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feypsilon%2Fget-used","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feypsilon%2Fget-used/lists"}