{"id":18879726,"url":"https://github.com/loilo/traceback","last_synced_at":"2025-10-28T22:12:03.124Z","repository":{"id":62518842,"uuid":"197224695","full_name":"loilo/traceback","owner":"loilo","description":"🐾 Get the file or directory calling your code","archived":false,"fork":false,"pushed_at":"2020-12-23T23:03:53.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T06:35:00.305Z","etag":null,"topics":[],"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/loilo.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}},"created_at":"2019-07-16T15:55:12.000Z","updated_at":"2020-12-23T23:03:56.000Z","dependencies_parsed_at":"2022-11-02T13:17:55.473Z","dependency_job_id":null,"html_url":"https://github.com/loilo/traceback","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/loilo/traceback","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loilo%2Ftraceback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loilo%2Ftraceback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loilo%2Ftraceback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loilo%2Ftraceback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loilo","download_url":"https://codeload.github.com/loilo/traceback/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loilo%2Ftraceback/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265703554,"owners_count":23814028,"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","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":[],"created_at":"2024-11-08T06:39:04.685Z","updated_at":"2025-10-28T22:11:58.089Z","avatar_url":"https://github.com/loilo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"Traceback logo: two dog footprints next to each other\" src=\"traceback.svg\" width=\"220\" height=\"176\"\u003e\n\u003c/div\u003e\n\n# Traceback\n[![Tests](https://badgen.net/github/checks/loilo/traceback/master)](https://github.com/loilo/traceback/actions)\n[![Version on packagist.org](https://badgen.net/packagist/v/loilo/traceback)](https://packagist.org/packages/loilo/traceback)\n\nGet the file or directory calling your code.\n\n## Installation\n```bash\ncomposer require loilo/traceback\n```\n\n## Usage\n`/var/www/foo.php`\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse Loilo\\Traceback\\Traceback;\n\nfunction foo()\n{\n    var_dump(\n        // File path calling foo()\n        Traceback::file(),\n\n        // Directory of file calling foo()\n        Traceback::dir(),\n\n        // File path calling foo() but skipping\n        // the first file in the chain\n        Traceback::file(1),\n\n        // Directory of file calling foo() with skipping\n        Traceback::dir(1)\n    );\n}\n```\n\n`/var/www/bar.php`\n```php\nrequire_once __DIR__ . '/foo.php';\n\nfoo();\n```\n\n`/var/www/baz/qux.php`\n```php\nrequire_once __DIR__ . '/../bar.php';\n```\n\nRunning `qux.php` will output:\n```\nstring(16) \"/var/www/bar.php\"\nstring(8) \"/var/www\"\nstring(20) \"/var/www/baz/qux.php\"\nstring(12) \"/var/www/baz\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floilo%2Ftraceback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floilo%2Ftraceback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floilo%2Ftraceback/lists"}