{"id":18821231,"url":"https://github.com/compwright/loaders","last_synced_at":"2025-09-19T17:55:24.912Z","repository":{"id":3988813,"uuid":"5084977","full_name":"compwright/loaders","owner":"compwright","description":"A core object loader and accessor for CodeIgniter","archived":false,"fork":false,"pushed_at":"2012-08-27T15:35:38.000Z","size":108,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-25T14:08:05.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compwright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-17T16:58:09.000Z","updated_at":"2020-06-17T20:50:00.000Z","dependencies_parsed_at":"2022-09-02T18:01:50.096Z","dependency_job_id":null,"html_url":"https://github.com/compwright/loaders","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Floaders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Floaders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Floaders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compwright%2Floaders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compwright","download_url":"https://codeload.github.com/compwright/loaders/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223612546,"owners_count":17173627,"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-08T00:36:15.468Z","updated_at":"2025-09-19T17:55:19.859Z","avatar_url":"https://github.com/compwright.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Overview\n========\n\n**Loaders** is a collection of loaders and accessors for CodeIgniter's core objects.\n\nAfter you write enough CodeIgniter applications, writing `$this` and manually\nloading stuff gets old. **Loaders** is an easier, globally-accessible way to\naccess core CodeIgniter objects such as libraries, models, `view`, and `db`.\n\nOriginally conceived as a plugin called \"Modularity\", this has been reborn\nas a CodeIgniter 2.0-compatible helper.\n\nFeatures\n========\n\n* Auto-load libraries, models, databases\n* Eliminates need to call `get_instance()` when you need to access framework\n  objects inside a model, library, helper, or view\n* Concise syntax\n* Supports multiple database connections\n* Requires PHP5 \u0026 CodeIgniter 1.5+\n\nInstallation\n============\n\nInstall and load *Loaders* as you would any other CodeIgniter helper.\n\nOr, use the [Sparks](http://getsparks.org/get-sparks) package installer:\n\n```\nphp tools/spark install -v0.0.1 loaders\n```\n\nUsage\n=====\n\nViews\n-----\n\nThe normal way to load and display a view is like so:\n\n```php\n$this-\u003eload-\u003eview('myview', $data);\n```\n\nWith the View loader, do it this way:\n\n```php\nViews::show('myview', $data);\n```\n\nOr if you want to return a string instead of outputting the view, do this:\n\n```php\n$pagetext = Views::parse('myview', $data);\n```\n\nLibraries\n---------\n\nThe old way to load libraries was like this:\n\n```php\n$this-\u003eload-\u003elibrary('mylibrary');\n$this-\u003elibrary-\u003edo_something();\n```\n\nWith the library loader, you can just do this:\n\n```php\nLibrary('mylibrary')-\u003edo_something(); // the library automatically loads if needed\n```\n\nModels\n------\n\nTo fetch data with a model, we used to do this:\n\n```php\n$this-\u003eload-\u003emodel('mydatamodel_model');\n$this-\u003emydatamodel_model-\u003edo_something();\n```\n\nNow, with the model loader, it works like this:\n\n```php\nModel('mydatamodel')-\u003edo_something(); // the model automatically loads if needed\n```\n\nDatabases\n---------\n\nThe old way to run a query on the default database connection:\n\n```php\n$this-\u003eload-\u003edatabase();\n$query = $this-\u003edb-\u003equery($sql);\n```\n\nUsing the database loader, it is easier:\n\n```php\n$query = Database()-\u003equery($sql); // the database automatically loads if needed\n```\n\nMaybe you have multiple connections?\n\n```php\n$query1 = Database('db1')-\u003equery($sql);\n$query2 = Database('db2')-\u003equery($sql);\n```\n\nGlobal access\n-------------\n\nThese loaders work anywhere in exactly the same way, including libraries, helpers, and views.\n\nPreviously, you had to get an instance of the `$CI` object to work with, which can be a drag:\n\n```php\n$CI =\u0026 get_instance();\n$CI-\u003eload-\u003emodel('mymodel_model');\n$CI-\u003emymodel_model-\u003edo_something();\n```\n\nNow you don't have to call `get_instance()` anymore!\n\n```php\nModel('mymodel')-\u003edo_something();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Floaders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompwright%2Floaders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompwright%2Floaders/lists"}