Broken output view from WSL terminal with Docker & Laravel - php

when i doing commands in terminal i got outputs looking like this:
As you can see, the problem is that the terminal does not display successive lines of the result from the beginning of the line, only from the place where the previously displayed line ends.
It is very uncomfortable to use today. The problem happens on the WSL console with the php artisan commands which I have to use because I have a project created with Laravel on Windows 11 using Windows Subsystem for Linux, Ubuntu and Docker.
How i can fix this?
UPDATE
The same happens when I use WSL outside of the IDE (PHPStorm), from the Windows directly in Ubuntu.

Related

PhpStorm - WSL2 - PHPUnit - Configure CLI Interpreter

I upgraded to WSL2 from Windows 10.
With PhpStorm, in my project that I switched under my WSL, I try to launch PHPUnit. But I have this error :
Error in bootstrap script:
Symfony\Component\Dotenv\Exception\PathException: Unable to read the
"\WSL$\UBUNTU\home\toto\symfony\myProject/.env" environment file.
By looking in the parameters at the CLI Interpreter level, I saw that there was still my Windows config:
So, if the problem is there, I imagine that I have to make sure to take the PHP Executable from my WSL. Except that .. well impossible to find it
I have the file in usr/bin/php, or usr/bin/php7.4, but neither is accepted. And in \etc\php\7.4, I have these 3 folders:
But the same, there's nothing in it that can be accepted.
You are using a PHP interpreter of the Local type, while you need to use the WSL type. Here's what the UI looks like:
Click the + icon, choose From Docker, Vagrant, VM, WSL, Remote..., and choose WSL in there.

How do I setup my host machine's PHP interpreter to point to the container's PHP interpreter

I would like to configure PHPStorm so that I can run Artisan commands directly from my IDE's terminal. For example php artisan key:generate. However, when I do, I receive the error 'php' is not recognized as an internal or external command.
Background:
running Windows 10 as host machine
using Docker to run my webserver (Nginx) and PHP interpreter (7.2-fpm).
I followed this tutorial.
https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose.
One thing the tutorial didn't cover was how to set up my remote PHP CLI interpreter. For that, I followed https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html and can make a successful connection as it picks up the correct PHP version 7.2.21 as seen in the screenshot.
After this, I restarted my Windows 10 host machine, fired up the container, opened my IDE and tried to run php -v from the terminal but hit the error again.
I know it has something to do with my PATH environment variable being set incorrectly, or not at all but I am not sure how to point it to the container's PHP interpreter. Any help would be greatly appreciated.
EDIT
For what it is worth, I know that I can exec into the container and run PHP commands from there, but thought I might be able to do it directly from my host machine by pointing to the container's interpreter.
The terminal in PHPstorm is the same as any other terminal on your computer. It doesn't automatically connect to docker to run the php -v command. If you want to run php from PHPstorm in docker you can right click the file:
Choose run:
And select your created docker interpreter as your runtime:
If the fix button doesn't show it can be configured through:
settings > Languages & Frameworks > PHP
And then clicking on the 3 dots at the end of "CLI interpreter"

How to use Laravel Homestead for development

I know this might sound really silly, but I'm kinda stuck and need help. I'm trying to use Laravel 5.3 and use Homestead as my IDE. I have previously worked on PHP using NetBeans and XAMPP, but the installation has always been a pain. I have no formal training and have learnt and used basic PHP on my own for my webpages.
I'm running a Windows 8-32Bit OS & here's what I've done so far:
I have downloaded Laravel using Composer.
I have installed Virtual Box & Vagrant.
I have installed Git Bash and ran vagrant box add laravel/homestead (Homestead.yaml was not found in my Homestead folder after running bash init.sh command. I downloaded it from Github and added there).
Set SSH Key.
Ran vagrant up in Homestead folder (the installation was complete).
Issues:
If I just type http://localhost:8000 in my browser, nothing happens. I have to run php artisan serve in the command prompt inside laravel directory and keep the prompt window open for the default Laravel 5 page to open.
If I type http://127.0.0.1:8000 in my browser, nothing happens at all.
So how do I use Homestead then for my development everyday ?
you can try
localhost/project-name/public
if you dont want to run php artisan serve

$path in Netbeans does not contain /usr/local/bin when running/debugging php

I'm working with Netbeans 8.0.2 on Mac. I have problems with exec statements. Within netbeans it seems it can't find commands that are available in terminal.
For example I have this execute statement:
exec('mongorestore --host='.$this->host.' -d '.$this->db_name.' --dir '.$this->schemaPath);
If I run:php restore.php from terminal it runs without incident and imports the data. However if I run/debug/unittest from within netbeans output window shows:
sh: mongorestore: command not found
Other commands like mysqldump also have this issue. How can I make sure these command work from within Netbeans?
To be clear, I can run these commands in the terminal in netbeans, the problem only occurs if I run/debug/unittest a php file.
UPDATE:
Running some more test I find that the path variable is different for Netbeans.
terminal: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
netbeans: /usr/bin:/bin:/usr/sbin:/sbin

Aptana Terminal - PHP in CLI

At the start I was trying to run php commands for Symfony in wondows cmd.exe
After a while i gave up.
Since I use Aptana, I tried to figure out how to do commands like
php app/console doctrine:schema:update --force
which is for Symfony2. But I cannot figure out of this is possible or not?
Since the Terminal in Aptana is Unix-style (looks like it anyway) I'd prefer doing php commands in Aptana Terminal
any help is appreciated.
To work you must have set in the PATH environment variable on your system the route to php, for example C:\wamp\bin\php\php5.3.10\, be sure to place the last \.
If you have open Aptana, restart it. After this you can try running in the terminal echo $ PATH, in the output list should contain the path to PHP that just entered.
To test the configuration, run php -version, if the output is the version of php installed, simply position yourself in the symfony directory and run php app / console.

Categories