PHP Track - Suggestion to improvements


I know that a track requires quite some maintenance, but I would like if we could improve the PHP track.

Disclaimer, I cannot help right now for personal reasons, but would love to help somewhen later, when I’m able again.

I have been PHP developers for quite some years, started early 2000 with PHP, so I have seen a line of code or two.

I would love to see the PHP track enforce some of the possibilities in PHP, instead of showing its weaknesses. Today I saw a test in PHP track that failed, because I have declared types on my properties. That should not be “punished”, that you write more strong typed code. I know there is a concept in the PHP track later, regarding types, but it should be included from the first lesson, in my opinion.

PHP doesn’t have the best reputation, unfortunately, so I think it’s important to teach the users on Exercism how to use PHP right, not how it can be used without any types etc.

I’m really passionate about PHP and don’t like to see when the language is not shown the respect that I think it deserves.

As mentioned in another thread today (1), I think PHP should always run tests against the newest version, and the difficulties described there, could perhaps be solved with the suggestion I made earlier (2) with composer.json,.

And as PHP is quite backwards compatible. A exercise done in PHP 8.0 would most likely not fail in PHP 8.3 unless some function got removed, and if that’s the case, it only fair that the exercise should be revisited, to learn about the change.

As mentioned in the disclaimer, I cannot help right now. But I will happily help later. I think it’s important to improve the PHP track it after all runs quite a large percentage of the web, the better we can teach people to use it, the better our experience on the web would be, at least on the PHP driven sites ;)

  1. Upgrade PHP test runner to use PHP 8.2+? - #3 by tomasnorre
  2. What about adding composer.json to PHP? like package.json in JavaScript - #8 by tomasnorre

Do note tracks are all volunteer maintained. Any track overhauls would need someone to commit the time and will to make the changes happen.

I am aware, I tried to be diplomatic in my post. I want to help later when I can, but for now we can start the discussion on how to improve, when I am later able to help.

I appreciate you don’t have the capacity now. I’m currently working through PHP and am also keen to improve it where I can.

If you can follow up with concrete items you would like to improve, that would be really helpful. “Today I saw a test in PHP track that failed” – what exercise and test specifically?

One of the hesitancies about allowing arbitrary 3rd party libraries is that the test runners do not have internet connectivity. Some other tracks have installed a selection of external libs (perl and go spring to mind), so if there are some essential libraries commonly acknowledged by the PHP community, I’m sure we can figure out something similar.


The test I was talking about was one in the Window System Exercise.

It failed as I declared type and default value for the property. Shouldn’t be “punished” for writing better code.

One of the most important improvement I would like to see if forcing people to use more types to ensure the could is less error-prone.

Besides that I would love to have it running against the newest version of PHP to get all the benifits.

E.g Had this today in the Robot Name Exercise:

const MAX_ROBOT_NAMES = 26 * 26 * 10 * 10 * 10; // Works
const int MAX_ROBOT_NAMES = 26 * 26 * 10 * 10 * 10; // doesn't work due to PHP version
public const int MAX_ROBOT_NAMES = 26 * 26 * 10 * 10 * 10; // doesn't work due to PHP Version

I think it’s correct to teach new developers what the language has to offer today, not what it offered earlier.

We need to improve the developers of PHP to improve the reputation of the Language.

Windowing System is a concept exercise, and these are special within the tracks. Besides respecting PHP lowest version supported, these focus on the newly introduced concept and are not intended to play with, meaning solving in other ways as requested or with advanced concepts.

Nevertheless, I agree with you that types there could be allowed without negative consequences. On the other hand default values (other than null) are not possible, because these would prevent ensuring setting default values in the constructor as intended for the concept learning goals.

Regarding the Robot Name exercise, PHP8.3 features cannot be used as long as the track does not support PHP8.3 in testing infrastructure. You are welcome to help with making that possible.

I’m not totally sure, if Exercism is the place to improve programmers in a way, that PHP’s reputation is improved (nor JavaScripts, or any other language). Most students will need years to gain the expertise, not to do things the easiest way possible. You may have learned that already, I know enough people that haven’t. Even after years programming, even after years failing on larger projects because of a lack of discipline.

Thanks for your reply. As mentioned earlier, I cannot help with bigger things right now. But later I would be happy to help out with some changes/improvements.