Javascript frameworks work nicely with php acting as an api. An even better approach is a hybrid that allows you to use a framework like Vue/React or a libruary like jQuery but also allows you to use php to power your pages. This gives you the ability to have an spa per section.
A common approach is to use an api to deliver data to your mobile app. If you've built it in php that can be reused.
Take this built-in php function: array_column
array_column() returns the values from a single column of the input, identified by the column_key
To perform the same in Javascript you either need to write something or find a package. There are many examples like this of build-in useful functionality.
PHP allows you to do a lot with very little code which allows you to focus on a difficult problem rather than a difficult problem and how to shape it with whatever language.
Keep learning javascript but don't try to do everything with it. Ignoring php, ruby or python on the backend will slow you down. Ignoring sql would be another mistake.
If the only motivation for learning a language is applicability to the job field, javascript probably will open more doors at this point, depending on your location.
PHP is really great for getting MVPs out the door in my experience, but a productive engineer in any language would likely have the same experience in the language of their choosing. I am by no means a PHP developer though.
Having said that, PHP and JS aren’t the only ones. You will also find Java, Python, Ruby, C# for examples.
> PHP does not solve any problem JavaScript can’t
Any language will solve anything you can do in any other language.
> JS is also more in demand
Depends on industry, location and even teams at the company as well as the standards and requirements which could vary by project.
Having said all that, if you‘re learning JS, yes, you can find jobs that use it.
If you become a great Javascript dev it will open you to far more opportunities, front end, back end, and everything in between.
PHP matters and if anything it would be good for you to learn both. It will give you a better insight on different ways to build software and use the appropriate solution.
PHP is a mature ecosystem with reliable tools/frameworks. It is relatively easy to learn and you can become productive quickly.
One benefit I find of PHP that is less mentioned:
When your team is short on people (and that happens quite often), you can pretty much throw anyone (provided they are generally competent) at a PHP codebase and they will do well. Wouldn't say the same for a back-end JS project, I've seen what a Java developer can do to a JS codebase.
PHP bites far less often than JS in my opinion.
* quick web scraping script (just with curl or file_get_contents) not the insane https-request-libs
* parsing some CSV files and generate SQL statements
* one-page website for monitoring/dashboard
* logging scripts (speed test hourly - working on article)
Even built a CLI xml feed processing system with it. Php7 is really fast and memory efficient. Not saying there aren't better or faster languages.
Guess its just a tool a reach for often, since I know it well and you can get far with a basic install without loading 1000 of npm/js packages. I only seldom need to use composer for my my* purposes.