Sign inSign up

softjpn/laravel-nodejs-dev

By softjpn

•Updated almost 2 years ago

A Docker image with PHP, Composer, Laravel, and the latest Node.js.

Image
Languages & frameworks
0

416

softjpn/laravel-nodejs-dev repository overview

⁠Laravel & Node.js Development Environment Image

Source Code on Github⁠

This repository provides a Docker image based on php:8.2-fpm with commonly used development tools pre-installed. It includes:

  • PHP 8.2
  • Composer (for PHP package management)
  • Laravel Installer (for quick Laravel project setup)
  • Git (for version control)
  • Node.js & npm (for JavaScript development)

By mounting your local working directory into the container, you can immediately utilize laravel, php, git, npm, and other tools without installing them on your host machine.

⁠Features

  1. PHP 8.2: Latest PHP interpreter for running your scripts and applications.
  2. Composer: Allows you to manage PHP dependencies.
  3. Laravel Installer: Quickly scaffold a new Laravel application.
  4. Node.js & npm: Allows you to run Node.js scripts and manage packages.
  5. Git: Convenient for version control operations.

⁠Usage

Below are common usage examples. In all commands, -v "$PWD:/app" mounts your current directory to the container’s /app directory. This means any commands you run inside the container will affect files in your local directory.

⁠1. Create a new Laravel project
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev laravel new example-app

Explanation:

  • docker run --rm -it: Runs a temporary container interactively and removes it upon exit.
  • -v "$PWD:/app": Mounts your current directory on the host to the /app directory in the container.
  • softjpn/laravel-nodejs-dev: The name of the Docker image.
  • laravel new example-app: Uses the Laravel Installer to create a new Laravel project named example-app.
⁠2. Run a simple PHP script

Suppose you have a file named helloworld.php in your current directory. You can run it like this:

docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev php helloworld.php

Explanation:

  • php helloworld.php: Tells the container to run your local helloworld.php using PHP.
⁠3. Run a simple NodeJS script
laravel-nodejs-dev docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev node ./helloworld.js
⁠4. Check PHP version
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev php --version

Explanation:

  • php --version: Outputs the PHP version installed in the container.
⁠5. Use Git
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev git --version

Explanation:

  • git --version: Outputs the Git version installed in the container.
  • You can also run other Git commands, such as commit, push, pull, etc.
⁠6. Check npm version
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev npm --version

Explanation:

  • npm --version: Outputs the npm version installed in the container.
  • You can also run other npm commands (e.g., npm install, npm run dev, etc.).

⁠Additional Notes

  • Default Command: When no command is specified, the container runs php-fpm. Typically this is used in a larger Docker Compose setup for Laravel applications.
  • Working Directory: The container uses /app as its working directory, so remember to mount your project into /app.
  • Entry Point: The entry point is set to use docker-php-entrypoint, ensuring that PHP-FPM or any PHP commands will run correctly.

This image is designed to be a versatile and lightweight development environment. It streamlines your workflow by bundling several frequently used tools into a single container, allowing you to keep your local development environment clean while still having powerful, up-to-date tools at your disposal.

Tag summary

Content type

Image

Digest

sha256:0c59e9919…

Size

267.1 MB

Last updated

almost 2 years ago

docker pull softjpn/laravel-nodejs-dev