I've been trying to set up my CI environment on AppVeyor since I need SQL Server. I can't seem to get laravel dusk working with it. I've managed to
Install PHP
Setup SQL Server 2012
Install Composer and all the packages
Install all my npm packages
Install the PDO SQLSRV drivers
and run a small script to create the .env file for testing but when I finally run
php artisan dusk
there's like 4 errors and 1 failure out of my 5 assertions
Here's an image of the tests failing: https://i.gyazo.com/98f3bc4ae979793eb4af62e97d90080d.png
The tests work on my local machine and I'm trying to automate it. I have no idea how to access my app while it's being tested so I've just put a localhost in the APP_URL of my environment configuration file(Laravel specific).
I'm trying to figure out how to get browser testing working on it. I've also installed chrome for chromedriver to be used in Dusk. Any help would be appreciated
Related
I am trying to clone a Laravel project into VSCode and run the project on a local server. I have imported Remote - WSL, but it won't let me set up a composer. I get: this error message when using php command in the terminal
I don't know what to do from here. Is there any other way to simply clone a project?
A popular option is to use a pre-configured program like MAMP / WAMP / XAMP which gives you the stack you need to run php code locally.
Alternatively you can set up you local environment for php and solve the error you are getting...
The error suggests you need to install php globally on your system :
https://www.php.net/manual/en/install.windows.php
https://www.php.net/manual/en/install.macosx.php
And to install composer:
https://www.hostinger.co.uk/tutorials/how-to-install-composer
I have an application developed with Symfony 5, which is working fine in my local environment (Vagrant running Laravel Homestead box), but when I deploy it to the live server it crashes with an empty white page and responds with 500 Internal Server Error.
When I SSH into the server and manually change the APP_ENV variable's value to dev from prod inside my .env file, I can see the error:
Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".
Did you forget a "use" statement for another namespace?
I'm using Github Actions to deploy my application and in my action I'm installing the PHP dependencies like this
- name: Install dependencies
run: |
export APP_ENV=prod
composer install --no-dev --optimize-autoloader
So I don't want development only dependencies in my production server, hence the --no-dev flag, and if I understand correctly the WebProfilerBundle is used for inspecting the request in development, so it's indented to be used only in the dev environment.
Why does Symfony think it has to load this bundle?
Also, I supposed to have my custom error pages configured for 404 and 500 errors (adding a bundles/TwigBundle/Exception/error.html.twig file under the templates folder), why isn't my custom error page shown? Why am I getting an empty white page?
I'm suspecting it's something with the way I'm deploying (since it work on my local machine).
I've tired removing the flags from the composer install (so just running composer install as is), but that also resulted in an error.
You can view my deployment action here.
Also here's the link to the repository.
The app's supposed to run on this domain: https://thebedechkacase.com/
Check your config/bundles.php and be sure to set Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true]. If i understood correctly your app is trying to load class which is not present under composer. Also be sure to clear cache on prod (php bin/console cache:clear). Also be sure that your production server have no .env.local file (or it's APP_ENV should also be prod)
Both the comment of #floGalen and #Gordy's answer were pointing me in the right direction, so thanks for that.
But the exact anwser came from reading Symfony's guide on deployment.
If you get a “class not found” error during this step, you may need to
run export APP_ENV=prod (or export SYMFONY_ENV=prod if you’re not
using Symfony Flex) before running this command so that the
post-install-cmd scripts run in the prod environment.
Since I wasn't using Symfony Flex I also needed the SYMFONY_ENV variable set to prod.
In addition I had my .env in the repo - which was actually only the one with development data and APP_ENV=dev, the "real" .env file was created during the deployment processes on the runner, retrieving it's value from Github's secret's store. Now the additional problem was that I first checked out my code to the runner, then run composer install then created the production .env (overwriting the one checked out from the repo), so composer install actually run with the dev settings. To fix this I moved the creation of my env file right before running composer install --no-dev --optimize-autoloader, then also did export SYMFONY_ENV=prod.
The combination of these two solved my issue!
I've inherited a Symfony/PHP web app codebase with zero documentation. I'm a nodejs dev so you can image the fun...! Anyway I'm getting there, my focus atm is to be able to run the project locally.
Here's the Symfony version:
Symfony version 2.7.16 - app/dev/debug
I've installed packages via composer install.
I can start the web app locally via CLI:
php app/console server:run
Server running on http://127.0.0.1:8000
Quit the server with CONTROL-C.
However when I try to access this URL I'm seeing the following error in browser. Have google'd around but couldn't work it out so am hoping someone here can point me in the right direction.
I think this is due to trying to run a new version of twig on an old version of Symfony
as you can see here: https://github.com/symfony/symfony/issues/20284
They mention something similar, perhaps try to include an older version of twig in composer?
composer require twig/twig 1.23
I came from frontend stack so I can misanderstand something when I'm learning symfony3.
I downloaded Symfony according to documentation with:
php -r "readfile('https://symfony.com/installer');" > symfony
To make php command available i added some values to the enviroment PATH variable (according to this tutorial: https://seiler.it/installing-symfony-framework-into-xampp-for-windows/ - step 2.3) like this:
c:\xampp\mysql\bin;c:\xampp\php;c:\xampp\php\PEAR;C:\xampp\php\symfony
As you see I'm using xampp for PHP development. I added that last, because i copied that downloaded symfony file to c:\xampp\php\symfony directory.
OK, now if i want to use symfony command, like
symfony new project
I need to go to directory where there is that symfony file and add 'php' before, like
php symfony new project
Because simple 'symfony new project' doesn't work (error msg tells about that command isn't known by Windows). How can i fix it?
In frontend there is something like npm (node package manager) with which you can install library/tool locally in directory or globally (to run it in terminal from any place on the computer). Is there is any equivalent in PHP development? I tried to install this by pear (from mentioned tutorial in step 7), but it installed me symfony 1.x version (and error of running that command was that there is no task like 'new') and i want to learn 3, not 1.
I tried to get composer, but i don't see where can i install there symfony globally.
So, how to run symfony globally? What am I missing?
From this doc:
In Windows, move the symfony file to a directory that's included in the PATH environment variable to create the global command or move it to any other directory convenient for you
idea
Install and use Git Bash. Gives you more futures then the windows CLI.
Performance
To run a ten times more fast environment for Symfony i prefer a Linux OS.
I'm been at this for days with no success. Running Laravel 5.1.
As I understand according to the Laravel doc.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit. Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. Its does not actually run any tests.
I searched more and came across a post that mentioned it could be a symlink issue. I followed the instructions in the post with no success. From memory I installed Laravel from composer so the symlink should not be an issue anyway.
These instructions involved deleting various files. I did notice that composer was pulling files from its cache when updating. So I cleared its cache and followed the process again. Still no success.
What are the tests not running? I'm at my wits end. Especially since its is supposed to run easily out the box.
In the end I was not calling the bat file correctly. I was running
C:\localhost\myProject\vendor\bin> phpunit
Instead I needed to run
C:\localhost\myproject> call vendor\bin\phpunit
Hence it now is referencing the phpunit.xml file with the test location information.
You need to install phpunit globally:
composer global require phpunit/phpunit
Then you can run phpunit from your project root.
You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit, that way the tests will execute the way they should be and you could get feedback in case it fails.
For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests.