Category : symfony

I have a PHP (Symfony) app which I created a Dockerfile from. Dockerfile FROM ubuntu:20.04 ENV PHP_VERSION=7.4 PHP_FPM_USER=www-data # Install required system packages and dependencies RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y –no-install-recommends php-fpm php-cli php-gd php-pgsql php-xml zip unzip curl && mkdir -p /run/php/ && sed -i ‘s/^listen = .*/listen = 0.0.0.0:9000/’ /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf ..

Read more

I’m using api-platform 2.5 in a Symfony 5.1 project. I want to implement multipart/form-data in API Platform as here in this doc https://api-platform.com/docs/core/file-upload/ Basically you just need to add: * "openapi_context"={ * "requestBody"={ * "content"={ * "multipart/form-data"={ * "schema"={ * "type"="object", * "properties"={ * "file"={ * "type"="string", * "format"="binary" * } * } * } ..

Read more

I’m writing a shopping cart page for shoes shop website using sessions in Symfony for PHP. It enables to add an item of selected size to cart and count a quantity. Here’s a function of adding a product: public function add($shoesid, $sizeid, SessionInterface $session) { $cart = $session->get(‘cart’, []); if(!empty($cart[$shoesid][$sizeid])) { $cart[$shoesid][$sizeid]++; } else { ..

Read more

Symfony 5.1.8 phpunit 7.5.20 php 7.4.12 When I run the tests without specifying a file, phpUnit can’t find any file. Folder Structure tests ├── bootstrap.php ├── TestTools │   └── MockService │   └── Helper.php └── UnitTests ├── WorkingExample2Tests.php └── WorkingExampleTests.php phpunit_phpstorm.xml <?xml version="1.0" encoding="UTF-8"?> <!– https://phpunit.readthedocs.io/en/latest/configuration.html –> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="./tests/bootstrap.php" > <php> <ini ..

Read more