{"id":22092096,"url":"https://github.com/krakphp/mw-codeigniter","last_synced_at":"2025-03-23T23:44:51.528Z","repository":{"id":57009028,"uuid":"75604396","full_name":"krakphp/mw-codeigniter","owner":"krakphp","description":"CodeIgniter Integration with the Mw Http Framework","archived":false,"fork":false,"pushed_at":"2016-12-05T08:35:27.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T06:52:19.515Z","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/krakphp.png","metadata":{"files":{"readme":"README.rst","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":"2016-12-05T08:29:12.000Z","updated_at":"2017-11-27T02:23:01.000Z","dependencies_parsed_at":"2022-08-21T13:10:13.076Z","dependency_job_id":null,"html_url":"https://github.com/krakphp/mw-codeigniter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fmw-codeigniter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fmw-codeigniter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fmw-codeigniter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krakphp%2Fmw-codeigniter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krakphp","download_url":"https://codeload.github.com/krakphp/mw-codeigniter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186922,"owners_count":20574554,"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-12-01T03:08:19.569Z","updated_at":"2025-03-23T23:44:51.509Z","avatar_url":"https://github.com/krakphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mw Http CodeIgniter Integration\n===============================\n\nYou can integrate the Mw Http framework with CI by embedding an Mw app inside of the CI\nframework.\n\nThe idea for this integration came from a legacy site I've managed before where we couldn't remove the old CI framework, but we needed to add new features that the Mw Http Framework could solve. So, this allows a nice bridge from an older system to a new one.\n\nInstallation\n------------\n\nInstall with composer at ``krak/mw-codeigniter``\n\nUsage\n-----\n\nTo have an app that you want to embed inside of the CI framework, you'll need to do a few things.\n\n1. Create a controller to handle the Mw Routes named like `application/controllers/mw.php`\n2. Create your mw app inside of the controller method.\n\n.. code-block:: php\n\n    \u003c?php\n\n    use Krak\\Mw\\Http;\n\n    class Mw extends CI_Controller\n    {\n        public function index() {\n            $app = new Http\\App();\n            $app-\u003ewith(Http\\Package\\std());\n            $app-\u003ewith(Http\\Package\\codeIgniter($this));\n\n            $app-\u003eget('/a', function() {\n                return '/a';\n            });\n            $app-\u003eget('/b', function() {\n                return '/b';\n            });\n            $app-\u003eget('/exception', function() {\n                throw new \\InvalidArgumentException('Whoa!!!!');\n            });\n\n            $app-\u003eserve();\n        }\n    }\n\n3. Register the default route to point to your mw/index action. All undefined routes will lead to it now.\n\n.. code-block:: php\n\n    \u003c?php\n\n    $route['404_override'] = 'mw';\n\nMake sure to add the CodeIgniter package last or at least later on in the packages.\n\nAPI\n---\n\nThese are all relative to the ``Krak\\Mw\\Http\\Package`` namespace.\n\ncodeIgniter($ci, array $config = [])\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nreturns a configured instance of ``CodeIgniter\\CodeIgniterPackage``. ``$ci`` must be an instance of the Codeigniter controller. ``$config`` is an array that allows the following configuration options:\n\nshow_stack_trace\n    Forwarded to `ciExceptionHandler`\n\nCodeIgniter\\\\ciExceptionHandler($show_stack_trace = true)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAn exception handler that will use the CI `show_error` global func to display the exception. ``$show_stack_trace`` determines whether or not to display the stack trace of the exception along with the exception message.\n\nCodeIgniter\\\\ciNotFoundHandler()\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSimply uses the ``show_404`` method from the CI framework to display a page not found.\n\nCodeIgniter\\\\ciViewMarshalResponse($ci)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAllows actions to return two-tuples of ``[string, array]`` which represent the view path and the data to load into the view. This internally uses the ``$this-\u003eload-\u003eview`` method in the CI framework.\n\nCodeIgniter\\\\CodeIgniterServiceProvider\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe service provider defines the following services:\n\ncodeigniter.server\n    This is a `Krak\\Mw\\Http\\Server` which serves from inside of the CI framework.\nserver\n    Replaces the `server` parameter with the `codeigniter.server` instance.\n\n**Required Parameters**\n\ncodeigniter.ci\n    An isntance of CI. This value is automatically filled if you are using the CodeIgniterPackage interface; however, it will need to be set if you are using the service provider on its own.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrakphp%2Fmw-codeigniter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrakphp%2Fmw-codeigniter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrakphp%2Fmw-codeigniter/lists"}