Learning PHP from other programming languages
PHP is a bit different from other languages, like Python or Dart, in that, it is a mainly a web programming language, running on a server. Furthermore, it is actually pre-installed in macOS.
I would actually recommend this -- https://phptherightway.com/, and it is quite updated.
Installing PHP
Although there are pre-installed packages for PHP, like XAMPP or MAMP, I would rather recommend installing separate parts normally, for learning; for the ease of installing packages: and for project management.
brew install php
- Install Composer
- Install Apache (
brew install httpd
) or Nginx (brew install nginx
); and set it up.- It seems that Apache is easier to use, but Nginx is faster. Also, Nginx's config looks nicer.
PHP CLI programming
It seems that in the end, PHP is not only for web servers. CLI app programming can also done…
// script.php
<?php
// Your code here
PHP in HTML
Although this was originally the intent of PHP, it doesn't seem to be a good practice to intermingle PHP and HTML in the same file (just like JavaScript).
PHP web frameworks
Of course, that is where I am coming from…
Downloading a repo from the internet / use a project scaffold
For the purpose of testing, I use Bolt CMS.
However, in order to upload to Heroku, you have to set your own web server, like no other programming languages -- https://github.com/patarapolw/bolt-heroku#deploy-bolt-on-heroku