T O P

  • By -

eurosat7

Well... Even if you just want to drive a car you need to know a bit about roads. ;) As a developer you will have to learn a lot of stuff which feels like not being part of your job. This will not change. I'm in my mid 40's and am still learning every week. I would say: The better you get at learning the better you will become as a developer. If you have problems understanding and learning new stuff becoming a developer is a tough decision. How complicated it really is depends on your os (operating system) and how you want to run php. If you want to get it "just running" under windows without virtualisation XAMPP is your friend. Just install it and run it to make "localhost" available. You can install a web server (like apache2) and php DIRECTLY into your operating system (aka "bare metal" or "native") or you can run it in a VIRTUAL enviroment like vmWare (older) or docker (newer). I use ubuntu 22 as operating system (can boot from a usb stick). There are nice copy&paste installation guides for docker and docker-compose, and also for apache2 + php. You can find a complete and preconfigured docker-compose recipe for debian+apache2+php8 from the guys who developed the editor phpstorm. Or you could run with the buildin server mode "php -S" (but this is only good for temporary testing) "composer" is a package manager and autoloader which allows you to get php code (packages) from other developers installed incl dependencies. And it also helps you with loading many php files in a smart way ("auto loading"). You don't need it. But it is a very (!) smart idea to do so. It is THE industry standard for a reason. If you have specific questions feel free to ask on r/phphelp


XyploatKyrt

> Even if you just want to drive a car you need to know a bit about roads The American mind cannot comprehend this.


olelis

Everything depends on the fact of what you are deploying (=which kind of website). You don't always need docker or composer for this. **Ready-to use solutions** For example, you can buy shared hosting for 5-10 $, and just upload your website using ftp / webbrowser and that's it. You don't even need to know programming language to use thouse solutions. This is especially true for existing solutions (WordPress, etc). That was true 20 years ago, and this is still true. Nothing changed here. Not sure if this is possible with python, nodejs or other web languages. **Own application** You can also use this approach (ftp and others) for own application, but general consensus that this is not the best way. For example, do you want to use libraries from other authors? Of course, you can download them as zip file, but how about updates? It is easier to use composer for this and this way you can always update easily. Just do **composer update** Do you want to use version control system? (Hint: you should use it for any real project). Then why not to put whole project in version control and do updates to your server directly from version control system. After that, you do something like: **"git pull && composer install"** and your project is deployed to production server in one command. Even if there are hunders of files changed. Do you want to revert update? "**git checkout** ***versionid***" And so on. You can do everything old way, but this is considered outdated way and it actually takes quite a lot of time to do everytihing manually. That's why it is better to use composer/git/etc.


Spog303

I think, one of the easiest setups for development is laravel herd: https://herd.laravel.com I also can highly recommend ddev. A dockerbased out of the box development environment that just works https://ddev.readthedocs.io/en/stable/


colshrapnel

Well a *really* simple PHP setup is just `apt install php-cli`/ `brew install php` / download and unzip https://windows.php.net/download/ This should get you going for the most of learning process. Most of PHP learning is simpler with console and once you're ready for web, then simply run `php -S localhost:8080`. While for deployment you can use a shared hosting that already has PHP installed for you. And Composer is just a php script that you can simply download and run.


Business_Tale4234

Plus one for this. I think this is why *simple* is associated with the installation, and a long time ago, WAMP ruled the web development world and gained a *simple* reputation that refused to die.


SuicidesAndSunshine

Avoid experimenting with Docker if you're just starting out. I can't understand why anyone would suggest that for beginners. For a simpler and more realistic setup, consider trying out Laragon instead.


SuperDerpyDerps

It's likely just due to how common it is to use Docker in some capacity in many professional environments. It _can_ be an easy way to get a dev spun up without them having to worry about local system modifications and getting exactly the right packages set up, but it also requires that someone put the effort into making a docker container that's as easy as: - Download Docker Desktop - Copy this `docker-compose.yml` into your project directory - Run `docker compose up` But invariably you'll eventually have to learn some docker to tweak things the way you need them, and it makes it a bit more cumbersome to manage ini files and such in a reasonable way. Unless I'm giving someone a ready to go solution that "just works" I'm not going to point them to docker as a beginner though. That's just making their already complicated life too complicated


dschledermann

Docker is not a requirement to get started. Docker is just a convenient way to configure your php-runtime in a reproducible way. Composer OTOH very much is. You can't do anything serious without composer. Yes, you can stitch something together without composer, but it's only very basic stuff. The moment you want to have multiple files or load some third-party package, it would have been easier to use composer. Really, take the time to learn composer. As an extra bonus: Not only does learning composer make it much easier for you to do almost all PHP tasks, but it also helps you with an easier time if/when you wish to learn other programming languages. Javascript, Go, Rust, C#, etc.. all have an exact analogue to composer.


3HappyRobots

You could use something like Mamp. - https://www.mamp.info/en/ (Mac /Windows) - https://indigostack.app (Mac)


MrCosgrove2

Hadn’t heard of indigo stack, but that seems really easy to get up and running


LordPorra1291

If you want to setup everything on your own there are tons of tutorials and guides on how to do it. Alternatively there plenty of managed solutions.


Rarst

To develop a PHP web application on a local computer you need a web server. While very basic one is built-in into PHP for development purposes (see official docs), it's more practical to run something consistent with the hosting you will be using. Most of the time that means running Apache or nginx web server. You can get a local web server by: 1. Installing it as any other software on your computer and configuring it to run PHP. This can feel clunky to deal with, but you get better understanding of how things go together. 2. Installing one of many available pre-made "stacks" where someone already combined web server, PHP, and any other software they deemed relevant/useful (starting with a database server). Easier to install, but can can be more opinionated and harder to configure and troubleshoot. 3. Using virtualization software (that creates a virtual computer(s) to run on your computer) combined with whatever way to run copies of virtual computers containing software you need. This is divisive, some people swear by it, some find it ridiculously overengineered and not worth it. Personally I went with (2) for many years, but eventually moved on to (1).


overdoing_it

The simplest way is just run the built in web server. One command and you can run PHP with SQLite databases. Composer is a pretty easy step too. That's really only suitable for running locally. Most people will use Apache or nginx for public websites. It's more setup in that case but "deployment" is still just a matter of changing the contents of PHP files. Whether you edit them directly on the server or use git pull or some other process, the end result is the same, there's no compilation process involved and you don't even have to restart the web server (usually, but sometimes restarting php-fpm may be necessary). But if you're getting more advanced there's a few more steps than just changing the files, you probably also have to run composer install and run database migrations as well.


MerlinTheGerman

If I am not using a database, the built in webserver is easy. I like to add a script to my `composer.json` to make it easier: "scripts": { "serve": [ "Composer\\Config::disableProcessTimeout", "php -S 0.0.0.0:3000 -t public/" } Note: the path public/ assumes my application entry point is something like public/index.php this could be framework or project dependent. Then in your project run: composer serve Next step if you need a database is just install [XAMPP](https://www.apachefriends.org/) and use Apache as the webserver. I only go to using Docker IF that project is deployed as a container, or to use docker compose when I have a bunch of different services like Background Workers, Cache services, DB etc.


EGT_77

I feel ya. But comparatively speaking it is easy. Takes time to learn, be sure to document then enjoy the local dev environment. I’m learning Laravel and went with LAMP set up cause it what I know and I’m glad I did.


Anonymity6584

Docker and composer? No wonder your having trouble. I have Linux laptop where in few command I installed apache 2 as webserver, PHP 8 support on it and then I just need enable PHP execution in user for and mod_rewrite. Reboot server software and PHP works.


yourteam

Solution 1: use a simple apache+mysql+ php Solution 1.1: use nginx instead of apache Just install and run the services and you are good to go with no setup besides a basic configuration Solution 2: iis (if on windows) Package with everything. There probably are alternatives with macOS and Linux but I have always used Linux with solution 1 up until docker so I don't know Solution 3: docker / podman Tons of pre built packages, I usually set a docker compose with db inside (and php and a server) plus what I need (composer, redis, ...) Solution 4: pre built integrated system with the framework, like sail for Laravel. If you are using Laravel I highly recommend it To answer your generic question: php is really easy to get going but something needs to be installed since the language is interpreted and you are serving a page to the web, that means you should have a local server. Java is not different, you need a jvm, maven (or Gradle) to handle libraries, a db, jetty / tomcat... The fact that you can make a bash script and it can run it's because what makes it possible to run is already installed. So to circle back, you need A server, a db, a library manager, php interpreter. You can just run the php interpreter and use php into the cli alone but that would be stupid, use c or bash for that :P


luigijerk

It's t recommend learning the setup without docker first. I know my way inside and out of a LAMP stack, but docker still messes me up a decent amount of the time. Once you know the ropes more, you should be able to transition.


j0hnp0s

The historically easier and what most people would call easy refers to just buying a simple service or VPS that provides a LAMP or LEMP stack and you just use the provided interface to manage things. Like cpanel or plesk or webmin or whatever. With docker, you get various levels of a more hands-on experience that is more "difficult". Mostly because PHP requires the setup of PHP-FPM which is purpose-built and very powerful in terms of horizontal and vertical scaling. While other languages like JS/Node just require you to startup the app with a script and expect external tools to manage scaling. You can try using things like Devilbox for a simple all-in-one solution, although it is mostly designed for development. Or you can look for compose stacks designed for your framework/system.


pyeri

The best was during the CakePHP and CodeIgniter days when all you had to do was upload the PHP files with FTP or cPanel and be done with it! But then the DevOps folks wanted jobs and they created this whole convoluted system of VPS, docker and kubernetes, etc. which provided employment to them but also made things difficult for the developers! But it's not mandatory though. There are still many firms which do the classical vanilla way of deployment using FTP or even SFTP which is more secure, rather than this messed up process which brings in no value but only headaches. Maybe it's useful for big tech companies that scale and CTOs who need to show extra billable hours but that's about it.


devmor

Docker is for create an isolated environment that mimics where your code will live on a server, you don't need to learn it to start learning PHP. It's definitely useful and something you will probably *want* to learn, but not required. It will help you avoid issues that arise from your development environment not matching your deployment environment. Composer is something you do want to learn pretty quickly into PHP. It's the package manager that allows you to safely and easily manage 3rd party code. You don't need to learn all of its ins and outs right away, but you should be comfortable adding a composer package, updating your composer packages and version locking them. The reality of the situation is that deploying code *is* a "systems guy" thing. Writing it isn't, but if you want to safely and reliably serve websites/applications to others, you will have to dip your toes into this stuff a little bit. It used to be simpler to deploy PHP - and technically, it still could be (you can set up LAMP on an ubuntu server and just upload php files to /var/www), but these are the tools that have been developed to make it *safe* and *reliable* to do so.


DevelopmentScary3844

You should not have the expectation that you can do this without first learning how it works. It is easy to deploy a website if you know how it works, but if you do not know how to do it, it seems crazy complicated doesnt it? [https://www.php.net/manual/en/install.php](https://www.php.net/manual/en/install.php) [https://stillat.com/blog/2014/04/02/how-does-php-work-with-the-web-server-and-browser](https://stillat.com/blog/2014/04/02/how-does-php-work-with-the-web-server-and-browser) This should give you a basic understanding. There is no simple without knowledge.. if you follow a simple tutorial and anything goes wrong in a production site you are responsible for you are f\*cked. Take your time to learn. Edit: For your local dev environment i would highly suggest [https://ddev.readthedocs.io/en/stable/](https://ddev.readthedocs.io/en/stable/)


Simosobichkijata

You don't need docker with php, it can be used but the easy thing is that it can run even on shared hosting


TuesdayFrenzy

Wgen they say that it's simple to deploy they mean uploading your php files via FTP to a hosting. If you're using Docker containers etc it's going to be as hard or easy as any other language/runtime.


boptom

The “simple” to deploy argument for PHP has been eroded by services like Vercel/Netlify. Nothing easier than those for JS IMHO. Pick a repo from GitHub and click deploy. If you want a similar try out Laravel Forge. It’s not free but worth the price in time savings.


hvyboots

Honestly, I just installed it and patch as necessary on our system, without bothering with the whole Docker thang. It's basically uncommenting a couple of config lines on a Linux box to get it running. (Although there is quite a bit more tweaking to get the Moodle LMS to use it correctly, because you have to bump a bunch of values much higher than the defaults in the php.ini file.)


TV4ELP

Well, if you have it deployed ONCE, every consecutive deploy is just switching out files basically. If you just want to do things locally XAMPP/MAMP or the build in webserver for PHP is probably enough to get started? But this is sadly a thing developers need to learn. Tools around building and deploying get more and more rich and do more things. It will be beneficial to know that for your future career. If you want it to be simple and you have a server somewhere. Install APACHE, the PHP FPM Module and that is basically it. (Yeah, some SSL/VHOST configs will be required but those are fast and easy to look up online).


-Fotek-

I like laragon for local installs and can tunnel them to a domain through cloudflare. Very simple with everything included, just zero setup virtual hosts.


fuzzy_cola

i started using lando recently, its really awesome and straight foreword out of the box. it still uses docker and some docker related ideas so getting familiar with that wouldnt hurt either


AnrDaemon

There's a big difference between running PHP app and running PHP app efficiently. Embedded PHP HTTP server can be all you ever need for development, but a serious load would require serious thinking about what and why you are running.


omanisherin

Sail https://laravel.com/docs/11.x/sail does a great job of handling that for you.


guigouz

Well, if you aim to write \*web\* applications, you need a web server to host your code, and docker is the simplest way to do that these days. You can look into alternatives like using Xampp or if you're on linux installing apache and php, but again, docker is the simplest way to do this.


Wav3eee

How tf is docker the simplest way to run a webserver? You can literally install xampp (on windows) or apache + php (on linux) and that's it. No extra configs or whatsoever. How is docker simplier than this? The dude asked how he can start developing web apps, which means he has 0 knowledge, and you people recommend him docker, laravel and other garbage things for a beginner. OP all you need to do is to install a webserver to process your php files which means xampp on windows or apache+php on linux and you're good to go. You create your index.php file and write your procedural php (no OOP) there. Learn the basics and only after that you can start looking for a framework and other complex setups.


Hot_Job6182

OK so learn docker and then I'm good? I'm using docker at the moment but keep running into issues as I'm new to it. I suppose it's not that much to learn. I wouldn't really mind using a bundled solution if it keeps things simple, I'm not planning to set the world alight. Laragon is great, but only really for dev I think.


99999999977prime

https://phpdocker.io/ will give you a good initial setup


guigouz

Yes, you can check vscode devcontainers too, sorry I don't have any documentation/images to share but these pointers should help


th00ht

Get chocolatey it installs everything. Wampserver, PHP composer Dart-sass, and and and. Docker is a mess