Git Product home page Git Product logo

codeigniter4 / codeigniter4 Goto Github PK

View Code? Open in Web Editor NEW
5.1K 5.1K 1.9K 277.98 MB

Open Source PHP Framework (originally from EllisLab)

Home Page: https://codeigniter.com/

License: MIT License

HTML 0.06% PHP 98.18% CSS 0.62% JavaScript 0.53% Makefile 0.01% Python 0.07% Hack 0.01% Shell 0.15% Smarty 0.07% Batchfile 0.01% SCSS 0.25% Clojure 0.04%
codeigniter codeigniter4 framework-php hacktoberfest php php-framework php8

codeigniter4's Introduction

CodeIgniter 4 Development

PHPUnit PHPStan Psalm Coverage Status Downloads GitHub release (latest by date) GitHub stars GitHub license contributions welcome

What is CodeIgniter?

CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. More information can be found at the official site.

This repository holds the source code for CodeIgniter 4 only. Version 4 is a complete rewrite to bring the quality and the code into a more modern version, while still keeping as many of the things intact that has made people love the framework over the years.

More information about the plans for version 4 can be found in CodeIgniter 4 on the forums.

Documentation

The User Guide is the primary documentation for CodeIgniter 4.

You will also find the current in-progress User Guide. As with the rest of the framework, it is a work in progress, and will see changes over time to structure, explanations, etc.

You might also be interested in the API documentation for the framework components.

Important Change with index.php

index.php is no longer in the root of the project! It has been moved inside the public folder, for better security and separation of components.

This means that you should configure your web server to "point" to your project's public folder, and not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter public/..., as the rest of your logic and the framework are exposed.

Please read the user guide for a better explanation of how CI4 works!

Repository Management

CodeIgniter is developed completely on a volunteer basis. As such, please give up to 7 days for your issues to be reviewed. If you haven't heard from one of the team in that time period, feel free to leave a comment on the issue so that it gets brought back to our attention.

Important

We use GitHub issues to track BUGS and to track approved DEVELOPMENT work packages. We use our forum to provide SUPPORT and to discuss FEATURE REQUESTS.

If you raise an issue here that pertains to support or a feature request, it will be closed! If you are not sure if you have found a bug, raise a thread on the forum first - someone else may have encountered the same thing.

Before raising a new GitHub issue, please check that your bug hasn't already been reported or fixed.

We use pull requests (PRs) for CONTRIBUTIONS to the repository. We are looking for contributions that address one of the reported bugs or approved work packages.

Do not use a PR as a form of feature request. Unsolicited contributions will only be considered if they fit nicely into the framework roadmap. Remember that some components that were part of CodeIgniter 3 are being moved to optional packages, with their own repository.

Contributing

We are accepting contributions from the community! It doesn't matter whether you can code, write documentation, or help find bugs, all contributions are welcome.

Please read the Contributing to CodeIgniter.

CodeIgniter has had thousands on contributions from people since its creation. This project would not be what it is without them.

Made with contrib.rocks.

Server Requirements

PHP version 8.1 or higher is required, with the following extensions installed:

Warning

The end of life date for PHP 7.4 was November 28, 2022. The end of life date for PHP 8.0 was November 26, 2023. If you are still using PHP 7.4 or 8.0, you should upgrade immediately. The end of life date for PHP 8.1 will be November 25, 2024.

Additionally, make sure that the following extensions are enabled in your PHP:

  • json (enabled by default - don't turn it off)
  • mysqlnd if you plan to use MySQL
  • libcurl if you plan to use the HTTP\CURLRequest library

Running CodeIgniter Tests

Information on running the CodeIgniter test suite can be found in the README.md file in the tests directory.

codeigniter4's People

Contributors

atishhamte avatar bangbangda avatar dafriend avatar dcaswel avatar ddevsr avatar dependabot[bot] avatar devorama avatar iredds avatar jim-parry avatar kenjis avatar littlej avatar lonnieezell avatar mgatner avatar michalsn avatar mostafakhudair avatar najdanovicivan avatar natanfelles avatar neznaika0 avatar nowackipawel avatar nyufeng avatar paulbalandan avatar ping-yee avatar puschie286 avatar ridho1991 avatar rumpfc avatar sammyskills avatar samsonasik avatar sclubricants avatar totoprayogo1916 avatar ytetsuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter4's Issues

Test folder structure

Now we have only system test, and the tests folder is like this:

tests/
|--Autoloader/
|--CLI/
...

My question is where do we put application test files?

Reserved method name

Session/SessionInterface has function 'unset', but that is a reserved name in PHP7.
This propagates to Session/Session.

It doesn't look like the method is called anywhere, though there are lots of calls to the global function 'unset'.

Should the method be renamed?

Image Class

This class represents a single image file and provides many features to work directly with the image itself, whether GD, GD2, or ImageMagic is present, through Handlers. Provides many common solutions to tasks like:

  • Resize (with centering options)
  • Crop (with centering options)
  • Rotate
  • create thumbnail (with renaming options, like adding size to filename)
  • work with EXIF data
  • Watermark text or black and white image onto
  • Convert between common formats (?)
  • Reset orientation (see https://rtmedia.io/docs/troubleshooting/fixing-image-orientation-wordpress-uploads/ for brief discussion/solution) Ensure all rotations are covered.
  • Compress
  • Copy

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Provide Throttler Filter

Should provide a simple method that can be used to throttle, or rate limit any action with the following constraints:

  • Number of requests
  • Time Period (in minutes?)
  • Restrict per session?

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

SL Insight - classes should be unique per PHP file?

SL Insight reports an "info" item: Keeping only one class per file is a standard in the PHP community, since it promotes interoperability and maintainability.

Excluding Kint, we have three violators:

  • system/Debug/CustomExceptions.php
  • system/HTTP/Response.php
  • system/Router/Router.php

Each of these defines one or more namespaced exceptions, for clarity.

It seems silly to have each of these in their own file, given that they basically extend a parent Exception class. I am not sure if having these in separate files would complicate things like the classmap or loading time.

Thoughts?

Additional Logger Enhancements

  • Autoclean file names, replacing APPPATH, BASEPATH, etc values in file paths with the constant name. (Keeps any logging more secure)
  • Support more placeholders in message interpolation, like:
    • {file} and {line}
    • {env:...} Replaces tag with an environment variable matching the name in ...

Debug Toolbar Enhancements

Enhance the toolbar for better usability and display.

  • Support and track AJAX requests
  • Support additional data for timeline entries that will display just below the row when clicked, and be hidden at other times. Should have visual indicator. Primary use would be to display information about the queries - perhaps the first X characters in the query?
  • Ability to be minimized to icon?
  • Supports other display formats, mainly JSON and XML, that can be displayed based up on the format the client has requested.

Enhancement Checklist:

  • Component(s) modified
  • Unit testing updated
  • User guide updated
  • Securely signed commits
  • Conforms to style guide

SensioLab Insight configuration

Can we configure SL Insight to ignore the third party packages?
Kint, in particular, triggers a large number of deemed errors.
These should not be part of the framework analysis.

Would one answer be to keep third party stuff external to the system folder? eg in /vendor or in /thirdparty if we did not want to mess up conventional composer usage?

Rename the loader class

I see the Loader Class does not actually load a file, but it just locates non-class files. Hence I propose rename it to FileLocator and move it under the CodeIgniter\Autoloader namespace.

If you're ok with it I can take the burden :)

BaseConfig getEnvValue type juggling

For reference, the content of getEnvValue() currently looks like this:

if ($value = getenv("{$shortPrefix}.{$property}"))
        {
            return $value;
        }
        else if ($value = getenv("{$prefix}.{$property}"))
        {
            return $value;
        }
        else if ($value = getenv($property))
        {
            return $value;
        }

This would appear to prevent setting values such as 0, "0", an empty string, empty array, etc. You've worked around the boolean false by allowing conversion of the string 'false' in the constructor, but most of the other loose comparisons still apply within the getEnvValue() method itself. Fixing this would likely require three separate if comparisons using $value === false.

Ensure docs are updated for current code.

Need to make sure the docs match up to the current state of code. While I've got a couple of people assigned to this task, feel free to send PR requests for docs if you want!

Missing protocolVersion in response header

We can't see the Welcome page, because the response header is invalid.

HTTP/ 200 OK   <-- here
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.4
Cache-control: no-store, max-age=0, no-cache
Content-type: text/html; charset=UTF-8

We should set protocolVersion somewhere, but I'm not sure where should be.

phpDocumentor bug

phpDocumentor2 does not properly recognize the hinted return type in PHP7.
In order to generate phpdocs for CI4, the return types in method signatures have been commented out for now. They can be restored using a global search & replace once phpDocumentor has addressed their issue.

Desired: function banana(): fruit
Workaround: function banana()//: fruit

Or, for an interface...
Desired: function banana(): fruit;
Workaround: function banana();//: fruit;

Add support for foreign keys to the Forge

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Implement Content Secure Policy

Per the specs, implement helper functions for CSP. This would likely be additional methods in the Response class to handle it. It looks like this will likely require the use of a separate class, if only to provide a way to work with nonces for script and style tags.

Why is `$getShared = false` the default?

In Services, $getShared = false is the default.

    /**
     * The Response class models an HTTP response.
     */
    public static function response(App $config = null, $getShared = false)
    {
        if (! is_object($config))
        {
            $config = new App();
        }

        if (! $getShared)
        {
            return new \CodeIgniter\HTTP\Response($config);
        }

        return self::getSharedInstance('response');
    }

When I want to get the shared object, if I write Services::response(null, true);, it creates new App object.

If the code is like the following, I could write just Services::response().

    public static function response(App $config = null, $getShared = false)
    {
        if ($getShared)
        {
            return self::getSharedInstance('response');
        }

        if (! is_object($config))
        {
            $config = new App();
        }

        return new \CodeIgniter\HTTP\Response($config);
    }

And in the system code, it seems we have more true use cases than false cases.

My question is, do you have any reason that we set the default false?

Database to fire events

I've been thinking about how the toolbar collectors work lately, and think it might make more sense to have some of the modified to fire events instead of storing data that is accessed by the Collectors. This is cleaner code, and allows for a lot more flexibility. The database engine is the first one that really makes to me. By having events fired off listeners could be provided that:

  • collect data to be shown in the Debug Toolbar
  • analyze queries to automatically detect slow queries and tell the user
  • analyze queries (in MySQL) using EXPLAIN to detect queries that could benefit from rewriting or missing indexes.
  • etc.

This would require refactoring the Database class to fire an event, and create a new listener for collecting the query information.

Enhancement Checklist:

  • Component(s) modified
  • Unit testing updated
  • User guide updated
  • Securely signed commits
  • Conforms to style guide

Remove Query Builder caching

The caching built into the Query Builder just complicates things for no real reason that we can determine. Strip it out. Those that do use it can simple clone() the Query Builder if they need to, now that it's a separate class.

Refactor DB Backup to stream to file instead of holding in memory

Might make sense to move this to the Forge class? Probably not, though it would make sense if that was renamed to Schema...

Would love a backup and import function that could save out and read back the schema to the exact point. Could be a nice other option for migrations - complete database schema dumps by date....

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

getHeaders

windows OS
...\system\Debug\Toolbar\View\toolbar.tpl.php

$value) : ?>
                <?php if (empty($value)) continue; ?>
                <tr>
                    <td><?= esc($value->getName()) ?></td>
                    <td><?= esc($value->getValueLine()) ?></td>
                </tr>
            <?php endforeach; ?>

var_dump($headers);

from this it follows that $value === string or $value === array

array(14) {
["Host"]=>
array(2) {
[0]=>
string(7) "ci4.loc"
[1]=>
object(CodeIgniter\HTTP\Header)#9 (2) {
["name":protected]=>
string(4) "Host"
["value":protected]=>
string(7) "ci4.loc"
}
}
["X-Real-IP"]=>
string(9) "127.0.0.1"
["X-Forwarded-For"]=>
array(2) {
[0]=>
string(9) "127.0.0.1"
[1]=>
object(CodeIgniter\HTTP\Header)#11 (2) {
["name":protected]=>
string(15) "X-Forwarded-For"
["value":protected]=>
string(9) "127.0.0.1"
}
}
["Connection"]=>
array(2) {
[0]=>
string(5) "close"
[1]=>
object(CodeIgniter\HTTP\Header)#12 (2) {
["name":protected]=>
string(10) "Connection"
["value":protected]=>
string(5) "close"
}
}
["User-Agent"]=>
array(2) {
[0]=>
string(78) "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"
[1]=>
object(CodeIgniter\HTTP\Header)#13 (2) {
["name":protected]=>
string(10) "User-Agent"
["value":protected]=>
string(78) "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"
}
}
["Accept"]=>
array(2) {
[0]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"
[1]=>
object(CodeIgniter\HTTP\Header)#14 (2) {
["name":protected]=>
string(6) "Accept"
["value":protected]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"
}
}
["Accept-Language"]=>
array(2) {
[0]=>
string(35) "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"
[1]=>
object(CodeIgniter\HTTP\Header)#15 (2) {
["name":protected]=>
string(15) "Accept-Language"
["value":protected]=>
string(35) "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"
}
}
["Accept-Encoding"]=>
array(2) {
[0]=>
string(13) "gzip, deflate"
[1]=>
object(CodeIgniter\HTTP\Header)#16 (2) {
["name":protected]=>
string(15) "Accept-Encoding"
["value":protected]=>
string(13) "gzip, deflate"
}
}
["DNT"]=>
string(1) "1"
["Pragma"]=>
array(2) {
[0]=>
string(8) "no-cache"
[1]=>
object(CodeIgniter\HTTP\Header)#18 (2) {
["name":protected]=>
string(6) "Pragma"
["value":protected]=>
string(8) "no-cache"
}
}
["Cache-Control"]=>
array(2) {
[0]=>
string(8) "no-cache"
[1]=>
object(CodeIgniter\HTTP\Header)#19 (2) {
["name":protected]=>
string(13) "Cache-Control"
["value":protected]=>
string(8) "no-cache"
}
}
["Content-Type"]=>
bool(false)
["X-Real-Ip"]=>
object(CodeIgniter\HTTP\Header)#10 (2) {
["name":protected]=>
string(9) "X-Real-Ip"
["value":protected]=>
string(9) "127.0.0.1"
}
["Dnt"]=>
object(CodeIgniter\HTTP\Header)#17 (2) {
["name":protected]=>
string(3) "Dnt"
["value":protected]=>
string(1) "1"
}
}

SessionInterface: unset() vs remove()

I noticed that the session interface defines an unset() method. I'm thinking it's not a safe name because of php's unset() (that isn't a function, but a Language construct, as reported here).
I would use another name, such remove() or delete()

New Toolbar Collector for Events

Should show event name and timing, both in it's own tab and in the timeline.

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Headers must support multiple headers with same name

In HTTP/2 we can specify multiple static resources to be sent through Link headers. Our current implementation supports multiple values for a single header, but not multiple headers of the same name. We need to revise this to support multiple headers of same name to allow for HTTP/2 optimization.

[Test Helper] assertLogged

Create a new helper method for doing testing that allows us to assert that a log action was performed. Should allow verifying log level and message as options or maybe better as different methods?

API Response Trait

This trait would provide a standardized way to respond from controllers when creating an API. The primary benefits are 2-fold:

  1. More readable HTTP responses for a variety of common situations.
  2. Best practices for the responses will be used so the developer doesn't have to think about which HTTP status to use in each situation.

[NEEDS MORE INFO]

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Namespace for test case classes

The current test case classes has no namespace.
I think it is better they have also namespaces. It avoids class name collisions.

And in my opinion, it is the best that a test case class has the same namespace as the class under test.
In that case, we can write class names in test code with the same style as the class under test.

What do you think?

AutoRoute and method arguments

When AutoRoute, It seems if we add arguments to URI segments like http://localhost/controller/method/arg, the arguments are not passed to the controller method.

Just not implemented the logic yet?

SYSDIR

windows OS
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
var_dump(SYSDIR);
string(0) ""

Fix:
define('SYSDIR', trim(strrchr(trim(str_replace('', '/', BASEPATH), '/'), '/'), '/'));

Database Connection setDatabase() and getVersion() methods

In the BaseConnection and MySQLi\Connection, setDatabase() and getVersion() are missing their access/visibility keywords:

abstract function setDatabase(string $databaseName);
abstract function getVersion();

function setDatabase(string $databaseName)
{
}

function getVersion()
{
}

I would assume they should be public, but I figured I'd call it out just in case.

Add 'secure' option for Routes

There should be a way to enforce that a route can only be reached through HTTPS. This would be passed as an option to that route (or route group). If it's accessed via HTTP then it should be redirected to HTTPS.

Class 'Config\App' not found

Error

Class 'Config\App' not found

BASEPATH/CodeIgniter.php at line 163

155
156 Hooks::trigger('pre_system');
157
158 //--------------------------------------------------------------------
159 // Get our Request and Response objects
160 //--------------------------------------------------------------------
161
162 $config = new \Config\App();
163
164 $request = is_cli()
165 ? Services::clirequest($config)
166 : Services::request($config);
167 $request->setProtocolVersion($_SERVER['SERVER_PROTOCOL']);
168 $response = Services::response();
169

Redirect Security

To help address Unvalidated Redirects and Forwards, the redirect() method should be able to restrict the URL to only URL's that have been defined in the routes file.

This should take effect by default, when the app is set to require all URL's to be routed.

It would be nice to have a way for it to be able to auto-detect a whitelist of URLs that can be used for this, but will need to be determined.

[FilesCollection] Allow getFiles with dot syntax

We can currently check if a file exists using dot syntax to dig into arrays, but need to implement this feature for getFile() also.

Enhancement Checklist:

  • Component(s) modified
  • Unit testing updated
  • User guide updated
  • Securely signed commits
  • Conforms to style guide

Add indexing functions to Forge

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Enforcing signing

We are starting to get contributions from the community.
Should we start enforcing signing, eg GPG?

Reverse Routing

Need to add Reverse Routing ability to the router library for a couple of reasons:

  • Allows a simpler way to add links in views that protects against the route changing.
  • Will allow us to restrict the redirect() method to only routes that exist on the site (assuming that the app is requiring all routes to exist in the routes file. This helps to address the OWASP's Unvalidated Redirects and Forwards attack.

Problem with Code Coverage Reporting

Now I can't generate code coverage report.

[vagrant@localhost project]$ phpunit --colors --coverage-text=coverage.txt --coverage-html=coverage
PHPUnit 5.0.10 by Sebastian Bergmann and contributors.

...............................................................  63 / 272 ( 23%)
............................................................... 126 / 272 ( 46%)
............................................................... 189 / 272 ( 69%)
............................................................... 252 / 272 ( 92%)
....................                                            272 / 272 (100%)

Time: 15.86 seconds, Memory: 14.00Mb

OK (272 tests, 514 assertions)

Generating code coverage report in HTML format ...PHP Fatal error:  Cannot declare class CodeIgniter\PageNotFoundException, because the name is already in use in /mnt/project/system/Debug/CustomExceptions.php on line 49
PHP Stack trace:
PHP   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
PHP   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
PHP   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
PHP   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
PHP   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
PHP   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
PHP  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
PHP  11. include_once() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707

Fatal error: Cannot declare class CodeIgniter\PageNotFoundException, because the name is already in use in /mnt/project/system/Debug/CustomExceptions.php on line 49

Call Stack:
    0.0041     355592   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
    0.0349    1003128   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
    0.0349    1003240   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
    0.7600    4106488   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
   15.8625   10192872   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
   15.8630   10192928   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
   15.8650   10213464   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
   15.8651   10213464   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
   15.8651   10213464   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
   15.9923   10478424  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
   15.9972   10538168  11. include_once('/mnt/project/system/Debug/Exceptions.php') /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707

This is because of the following require:

--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -35,7 +35,7 @@
  * @filesource
  */

-require dirname(__FILE__).'/CustomExceptions.php';
+require_once dirname(__FILE__).'/CustomExceptions.php';

 class Exceptions
 {

The above patch fixes the error but then it seems it shows debug bar and raise another error:

PHP Fatal error:  Uncaught Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php:38
Stack trace:
#0 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(707): include_once()
#1 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(680): PHP_CodeCoverage->processUncoveredFileFromWhitelist('/mnt/project/sy...', Array, Array)
#2 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(178): PHP_CodeCoverage->addUncoveredFilesFromWhitelist()
#3 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php(24): PHP_CodeCoverage->getData()
#4 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php(144): PHP_CodeCoverage_Report_Factory->create(Object(PHP_CodeCoverage))
#5 /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php(68): PHP_CodeCoverage->getReport()
#6 /home/vagrant/.composer/vendor/phpunit/phpunit in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Fatal error: Uncaught Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Error: Call to undefined method PHP_CodeCoverage::renderTimeline() in /mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php on line 38

Call Stack:
    0.0059     355592   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
    0.0361    1003128   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
    0.0361    1003240   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
    0.5748    4106488   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
   15.0706   10192872   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
   15.0711   10192928   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
   15.0756   10213464   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:144
   15.0757   10213464   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
   15.0757   10213464   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:178
   15.3139   10653368  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:680
   15.3232   10683384  11. include_once('/mnt/project/system/Debug/Toolbar/View/toolbar.tpl.php') /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:707

Uploader Class

This is a new class that takes the place of CI3's File_Uploader class.

  • Must accept the current IncomingRequest object to get the files from in the constructor
  • Must use the FileCollection and UploadedFile class features
  • Must be able to work with multiple files at once
  • Should make it easy to create multiple thumbnails of each image with size appended to name
  • Should provide standard size limits and verification (both file size and image dimensions, if image)
  • Should provide option to reset the orientation so it displays correctly.

Most of the image features should be handled through a new Image class.

Development Checklist:

  • Component(s)
  • ... with PHPdocs
  • Unit testing
  • ... with >80% coverage
  • User guide updated
  • Classmap integration?
  • Securely signed commits
  • Conforms to style guide

Can't get Code Coverage

$ phpunit --colors --coverage-text=coverage.txt --coverage-html=coverage/
PHPUnit 5.0.9 by Sebastian Bergmann and contributors.

...............................................................  63 / 145 ( 43%)
............................................................... 126 / 145 ( 86%)
...................                                             145 / 145 (100%)

Time: 11.14 seconds, Memory: 10.00Mb

OK (145 tests, 268 assertions)

Generating code coverage report in HTML format ...PHP Notice:  Constant CI_VERSION already defined in /mnt/project/system/CodeIgniter.php on line 17
PHP Stack trace:
PHP   1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:154
PHP   5. PHP_CodeCoverage_Report_HTML->process() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:486
PHP   6. PHP_CodeCoverage->getReport() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php:68
PHP   7. PHP_CodeCoverage_Report_Factory->create() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:126
PHP   8. PHP_CodeCoverage->getData() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php:24
PHP   9. PHP_CodeCoverage->addUncoveredFilesFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:160
PHP  10. PHP_CodeCoverage->processUncoveredFileFromWhitelist() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:618
PHP  11. include_once() /home/vagrant/.composer/vendor/phpunit/php-code-coverage/src/CodeCoverage.php:645
PHP  12. define() /mnt/project/system/CodeIgniter.php:17

Notice: Constant CI_VERSION already defined in /mnt/project/system/CodeIgniter.php on line 17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.