I put my Symfony project into Docker, using a volume for my code. I want to user a php command (php app/console doctrine:generate:entities MyBundle:MyEntity to be precise).
When I try to use my php command outside docker, where my code is, nothing happen. But when I connect myself into my docker, the php command is running well.
Do you know why my php command is not working outside my docker ?
Thanks :)
Docker contains your PHP image, it is only accessible from your container. If you try to make your order out of your Docker, it will not just find PHP sources because they are containerized
Your Symfony application can find them because you have indicated the way to the sources Dockers, that's all :)
Related
How to setup "PHP IntelliSense" on Visual studio code with Laradock to use the PHP binary in the laradock_workspace_1 container?
I have tried to start Remote-containers: attach to running container..., then problem is I can´t access my git repo since its mounted on Windows.
In Windows I can´t access the PHP binary in the docker container, is it possible for vs code to access PHP some remote way(without open a new vs code in the container), so it will have all libraries and modules loaded. This is something I need to get PHP IntelliSense working in correct way? Now some of the autocomplete are not working for example all functions related to Eloquent.
I have found this but unfortunately I don´t understand how to get it work:
https://github.com/laradock/laradock/issues/2248
Any other suggestions on how to get autocomplete to work, without install same PHP version in Windows (I don´t want to pollute my system)?
Start with connecting to the Laradock workspace container (Remote-containers) and mount the folder:
/var/www/
This will allow you to access the files outside the container.
Then for PHP IntelliSense you should add this line to the settings file:
{
"php.executablePath": "/usr/local/bin/php"
}
It might be possible to export the port to php-fpm outside the container, but nothing I know how to do. You can also connect to the php-fpm container, but I think the workspace is more practical to connect to.
I want to test some Laravel applications on my basic shared host.
Currently I just upload my complete application including the vendor files, however this takes quite long.
Since I do not have ssh access to my host I'd like to know whether there's an option to run composer / artisan commands without this.
I found this link: Use Composer without ssh access to server (Second Answer) which describes how to run composer using http://phpshell.sourceforge.net/
However, I can change folders in the console etc. But I cannot run php commands - I always get internal server error.
Check if your shared hosting provider has console feature in their CP which allows to run shell commands. Maybe you'll be able to run commands from there.
As alternative, you could right your own artisan runner and call artisan commands from the code:
Artisan::call('migrate');
To run composer command from PHP code, use shell_exec:
shell_exec('composer update');
I have created a react-laravel project using laravel-mix. Right now I am run project using
npm run watch
php artisan serve
So by this, I access project by : http://localhost:8000
I have also worked in laravel. In laravel, if we want to access project without php artisan serve then we can access using : http://localhost/project_name/public.
Now my question is, how can I access/execute react-laravel project without php artisan serve? Is there any kind of way to access/execute project without port? Because I want to set up react-laravel on live server and I don't want to continue open terminal on server after code uploading.
I will really appreciate your feedbacks.
There are a multitude of ways to set up a laravel project. and it has nothing to do with the frontend suite you use whether its React or Vue, I will give you 2 options here to run a laravel application.
1. vagrant/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!
Doc Link
2. XAMPP/WAMP/ or any LAMP stack
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
Link
Personally I prefer Laravel Homestead since it contains everything out of the box for laravel Development. like PHP, Nginx, MariaDB, Node, etc...
Background
A php application in running in a Docker container. With docker-compose, this container is ran in a configuration together with a postgres database container and a lot of other containers.
Attempting to run my phpunit tests in phpstorm, I have created a Docker Remote Interpreter test configuration which runs the PHP application container.
Problem
The container complains that it can not connect to the database, which of course is not started because it's configured in the docker-compose.yml and not started up along with the single container used by PhpStorm.
Attempts to solve
A PHP Remote Debug can use a deployment, so I tried to create a Docker Deployment configuration which uses the docker-compose.yml (therefore starting all containers) and is launched before the PHPUnit launch, but I cannot select this deployment.
Starting the Docker Compose containers except the one from the PHP app and have it connect to it. This proves difficult, because they are on different networks, so the php app container still complains about not finding the database. I cannot configure which network the container uses in PhpStorm.
tl;dr
My PhpStorm project is a PHP application. This application can run in a Docker container which serves through nginx. I can run my PHPUnit tests in the container with a run configuration, but it also needs other containers which are not started up automatically.
Question
How can I use PHPStorm to run PHPUnit tests in a PHP application container together with the containers it depends on (already described in a docker-compose.yml)?
The answer is too long. I hope this 5 minutes video by Jetbrains TV helps you.
https://www.youtube.com/watch?v=I7aGWO6K3Ho
In short you need:
Configure Docker instance in PHPStorm
Configure new PHP Interpreter from Docker container
Configure PHPUnit to use your new interpreter
I play with docker for a while and I wanted to use this to build a PHP development environment.
With PHP I use composer.
Despite my research about using docker to build a devlopmenet environment, I essentially found sample code showing how to run an existing PHP app (but not how to make a development environment)
like : https://github.com/tutumcloud/tutum-docker-php
I don't really understand if I have to run composer inside the container or outside ?
Can you show me some examples where I have my source code in a directory on the host, shared with container via a docker volume and how to use composer with this setup ?
Thanks :)
interesting setup here :
geoffrey.io/a-php-development-environment-with-docker.html
available on github :
https://github.com/ubermuda/docker-symfony