ddev icon indicating copy to clipboard operation
ddev copied to clipboard

feat(codeigniter): add CodeIgniter 4 app type, fixes #7303

Open Franky5831 opened this issue 3 months ago • 21 comments

The Issue

  • #7303

I noticed there was not app type for the CodeIgniter 4 framework

How This PR Solves The Issue

I added the app type

Manual Testing Instructions

cd .gotmp/bin/darwin_arm64 # Choose an other directory if it doesn't fit your architecture or just use the absolute path
mkdir test-ci4                                                        
cd test-ci4
./../ddev config --project-type=codeigniter --docroot=public
./../ddev start
./../ddev composer create codeigniter4/appstarter
./../ddev launch

Automated Testing Overview

I created the following test functions inside the pkg/ddevapp/codeigniter_test.go file:

  • TestIsCodeIgniterApp_DetectsTrue
  • TestIsCodeIgniterApp_DetectsFalseWhenMissingFiles
  • TestBuildCodeIgniterDBConfig_MySQL
  • TestBuildCodeIgniterDBConfig_MariaDB
  • TestBuildCodeIgniterDBConfig_Postgres
  • TestBuildCodeIgniterDBConfig_UnknownTypeFallsBack
  • TestBuildCodeIgniterDBConfig_OmitDB
  • TestIsDBOmitted
  • TestCreateCodeIgniterSettingsFile
  • TestSetPathsAndUploadDirs

Release/Deployment Notes

I believe this does this affect anything else or have ramifications for other code and anything has to be done on deployment

Franky5831 avatar Nov 13 '25 21:11 Franky5831

If you could add [skip buildkite] to the end of your commit message when you do additional commits, it will save some resources. If you don't remember, it's OK.

rfay avatar Nov 14 '25 00:11 rfay

Sorry for the long wait, I just added the bats tests for CodeIgniter4.

To run ddev commands with the new app type I had to create a symlink from .gotmp/bin/darwin_arm64/ddev to opt/homebrew/bin/ddev I think that might have caused some problems with the certs, I could not curl https://projectname.ddev.site and had to curl http://projectname.ddev.site, in the commit I used https, is that ok? should I go back to http?

I used a different curl system, the -I flag uses the HEAD request method, CodeIgniter by default generates only one route that only accepts GET requests: Routes.php I used the -w "%{http_code}" flag to only get the status code, I had a older version of curl, normally it would return HTTP/1.1 200 instead of HTTP/2 200.

Franky5831 avatar Nov 15 '25 14:11 Franky5831

It's OK to use http in the test. Does the curl work manually against https?

I usually put a symlink in ~/bin/ddev to my built ddev version, and have a script to switch it on and off, but I think Stas does like you did.

I'll let the tests run now.

rfay avatar Nov 15 '25 14:11 rfay

@rfay no, the curls don't work with https manually, not even for other app types, I think it could be because I am using my version of ddev

Franky5831 avatar Nov 15 '25 15:11 Franky5831

Does it work in your browser?

Normally, the problem is that you haven't done mkcert -install and a ddev poweroff and ddev restart

There are also occasionally differences between the homebrew version of curl and the built-in version. You might want to check that. which -a curl will show you what's available, you can try both out.

rfay avatar Nov 15 '25 15:11 rfay

@rfay Yes, it works in the browser when i use https. When I run curl with https I get this error:

curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.

Franky5831 avatar Nov 15 '25 15:11 Franky5831

Please try using both the homebrew curl and the macOS curl. This isn't that important but it's good to know what's going on.

Are you on an old macOS version?

rfay avatar Nov 15 '25 15:11 rfay

Please try using both the homebrew curl and the macOS curl. This isn't that important but it's good to know what's going on.

I was sure I was on the one from brew, I just checked and which curl returned: /opt/anaconda3/bin/curl. I think it started using that one the time I installed conda.

I now switched to the one from brew (version 8.7.1 the latest version is 8.17). Now it works with HTTPS.

Are you on an old macOS version?

I'm on the latest: 26.1

Franky5831 avatar Nov 15 '25 16:11 Franky5831

So does using a normal curl work? It seems like trouble that something from "anaconda" could be default curl in your path. that could cause a number of problems.

rfay avatar Nov 15 '25 16:11 rfay

Yes, the normal curl (the one from brew) works, I deactivated conda: conda deactivate I hadn't used it in more than a year. My guess is that the curl from conda became the default curl in my system when I installed conda.

Franky5831 avatar Nov 15 '25 16:11 Franky5831

Why are there empty files in pkg/ddevapp/TestDetectApp/codeigniter? (At least put a comment in them if the idea is their existence means it's codeigniter)

I did it like for laravel and cakephp, they both have empty files. I'll add a comment in my CodeIgniter files where I explain what part of the framework they are so it's easier.

The key thing that is missing now is support in TestDdevFullSiteSetup.

Ok, I'll do that

You can use Shopware6 as an example, and use ddev/test-shopware6 as an example. I've given you full admin privileges on that repo.

Thanks, I just accepted

Make sure you know how to manually test, because it will be way too painful to wait for the CI (and costly in resources). You'll use GOTEST_SHORT= and run the TestDdevFullSiteSetup locally. We can help if you need more help with that. There are helps in the developer section of the docs and training on ddev.com/blog as well.

Ok, I'll make sure of that

Franky5831 avatar Nov 18 '25 15:11 Franky5831

Why are there empty files in pkg/ddevapp/TestDetectApp/codeigniter? (At least put a comment in them if the idea is their existence means it's codeigniter)

I did it

The key thing that is missing now is support in TestDdevFullSiteSetup.

I just did it

Make sure you know how to manually test, because it will be way too painful to wait for the CI (and costly in resources). You'll use GOTEST_SHORT= and run the TestDdevFullSiteSetup locally. We can help if you need more help with that. There are helps in the developer section of the docs and training on ddev.com/blog as well.

The TestDdevFullSiteSetup ran succesfully for CodeIgniter, I tried to run it for all (without GOTEST_SHORT) but I just got this error: 403 API rate limit exceeded for MY IP WAS HERE I think you can run the CI.

Sorry it took me this long, I got lost with the ddevapp_test.go tests file.

Franky5831 avatar Dec 01 '25 23:12 Franky5831

I would like your opinion on the implementation inside the ddevapp_test.go file, I didn't use file tarballs like for other app types. In codeIgniter4 the uploads directory is writable/uploads which is not available to http requests, I would need to create a controller to handle the request, should I build it and add it to the repo? (I didn't to make updates easier) The files tarball is now useless.

Franky5831 avatar Dec 01 '25 23:12 Franky5831

  • If you need a static file for the test, just choose any static file. It doesn't have to be from uploads dir.
  • I think what you're saying is that file uploads are accessed dynamically, which means you can use one of them as the dynamic URI. I don't recommend adding a controller, we'd prefer to use things as they are in the underlying codebase (mostly).

rfay avatar Dec 01 '25 23:12 rfay

Rebased. It was quite a ways behind.

rfay avatar Dec 02 '25 13:12 rfay

Thanks for your patience on this!

https://github.com/ddev/ddev/actions/runs/19859819978/job/56915807860#step:13:14991

And since you're on a fork, the TestDdevFullSiteSetup doesn't run in CI, so please make sure it's running great locally.

rfay avatar Dec 02 '25 16:12 rfay

I'm working on the error

Franky5831 avatar Dec 03 '25 10:12 Franky5831

The last commit fixed this error. I don't understand this error, it seems unrelated.

Franky5831 avatar Dec 04 '25 17:12 Franky5831

I don't understand this error, it seems unrelated.

Congrats on the good work. I restarted the Colima test

rfay avatar Dec 04 '25 18:12 rfay

GREEN!

rfay avatar Dec 05 '25 02:12 rfay

@Franky5831 once again you did a merge to update (6577d68997b4972a3972449fc27881363aa5f51a)

This makes it ever so hard to keep the PR up to date. Please always use rebase. You can do it with the GitHub UI if you're uncomfortable with git rebase

rfay avatar Dec 12 '25 17:12 rfay

Reverted the merge commit and rebased.

rfay avatar Dec 12 '25 17:12 rfay

I just rebased using the github ui

Franky5831 avatar Dec 13 '25 14:12 Franky5831

With this commit I added the enviroment variable to the .env file generated from codeigniter.go:

CI_ENVIRONMENT = development

This way it doesn't hide errors, adds debugging tools and other dev tools. I also changed the structure of the .env file to be more inline with the sample env found in the framework, you can look at how it's structured here.

Franky5831 avatar Dec 15 '25 22:12 Franky5831