Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New post to help CodeIgniter 3 folks #6082

Open
wants to merge 1 commit into
base: 1.5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions website/src/_posts/codeignitor3-working-configuration.md
@@ -0,0 +1,56 @@
---
title: "A working PHPStan Configuration for CodeIgnitor 3"
date: 2021-11-24
tags: guides
---

Working with CodeIgnitor 3 can be tricky. However ondrejmirtes and webbgroup have been able to find a working configuration that inspects the PHP application, but not bring in all of the libraries that CodeIgnitor depends on.

The prerequsites will be you need to have phpstan already brought in through composer. Once that is completed, you'll need 2 additional things:

1. A bootstrap file, named phpstan-bootstrap.php
```
<?php

define('BASEPATH', __DIR__);
define('URI_PATH', 'URI_PATH_SECURE');
define('ENVIRONMENT', "development");

?>
```

2. A Neon Configuration, named phpstan.neon.
Customize the configuration as you wish. Just use this as a starting point.

```
# Run this in the base directory: ./vendor/bin/phpstan --debug
# https://phpstan.org/user-guide/getting-started
parameters:
level: 0
scanFiles:
- index.php
bootstrapFiles:
- phpstan-bootstrap.php
paths:
- .
excludePaths:
analyse:
- tests/*
- application/third_party/*
- assets/*
- system/*
- vendor/*
fileExtensions:
- php
ignoreErrors:
```

3. Lastly run this your root Codeignitor directory :-)

Debug flag is optional, but helps you understand how it works.

```
./vendor/bin/phpstan --debug
```

Happy Code Wrangling!