Installing mailgun bundle for Symfony breaks down "bin/console" command
How and where to get working mailgun bundle for Symfony 4?
$ composer require cspoo/swiftmailer-mailgun-bundle:*
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
- Installing php-http/discovery (1.4.0): Loading from cache
- Installing psr/http-message (1.0.1): Loading from cache
- Installing php-http/message-factory (v1.0.2): Loading from cache
- Installing clue/stream-filter (v1.4.0): Loading from cache
- Installing php-http/message (1.6.0): Loading from cache
- Installing php-http/promise (v1.0.0): Loading from cache
- Installing php-http/httplug (v1.1.0): Loading from cache
- Installing php-http/client-common (1.7.0): Loading from cache
- Installing php-http/multipart-stream-builder (1.0.0): Loading from cache
- Installing mailgun/mailgun-php (2.4.1): Loading from cache
- Installing cspoo/swiftmailer-mailgun-bundle (0.1.2): Downloading (100%)
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 2 recipes (9b46b734d14be831804cdcde063bdadf)
- WARNING mailgun/mailgun-php (>=2.3): From github.com/symfony/recipes-contrib:master
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/mailgun/mailgun-php/2.3
Do you want to execute this recipe?
[y] Yes
[n] No
[a] Yes for all packages, only for the current installation session
[p] Yes permanently, never ask again for this project
(defaults to n): y
- Configuring mailgun/mailgun-php (>=2.3): From github.com/symfony/recipes-contrib:master
- Configuring cspoo/swiftmailer-mailgun-bundle (>=0.1.2): From auto-generated recipe
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In ArrayNode.php line 238:
!!
!! The child node "key" at path "mailgun" must be configured.
!!
!!
!!
Installation failed, reverting ./composer.json to its original content.
Related
I got this in my bitbucket pipeline:
pipelines:
branches:
develop:
- step:
caches:
- composer
name: unit tests - Delivery
image: totersapp/laravel-docker:phpredis
script:
- echo "memory_limit=512M" > /usr/local/etc/php/conf.d/memory-limit-php.ini
- ln -f -s .env.pipelines .env
- composer install
services:
- postgres
- redis
every time it run it is downloading the same files (even on the second run).. any ideas why?
This is the log for composer install:
+ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 199 installs, 0 updates, 0 removals
- Installing kylekatarnls/update-helper (1.2.0): Downloading (connecting...)Downloading (0%) Downloading (100%)
- Installing ocramius/package-versions (1.4.2): Downloading (connecting...)Downloading (0%) Downloading (30%)Downloading (35%)Downloading (65%)Downloading (95%)Downloading (100%)
- Installing symfony/polyfill-ctype (v1.13.1): Downloading (connecting...)Downloading (0%) Downloading (100%)
update: couldn't override default
Based on this answer I tried this:
- step:
caches:
- composer
image: totersapp/laravel-docker:phpredis
script:
- composer install
..
definitions:
caches:
composer: /composer/cache
My problem is that I'm trying to call composer with a custom cache directory (in this case it's /composer/cache) but then again I don't have a way to call the composer install command while supplying the custom cache directory as an option (ie which is what the bitbucket tutorial is doing with bundle in this example:
- bundle install --path vendor/bundle
said another way, I cannot run something like this:
- composer install --cache-directory /composer/cache
Update 2: discrepancy between composer.json and composer.lock
First as a sanity check, I simply cloned the repo of Nico
Haase, and ran the pipelines, passed ✅
I copied and pasted the contents of his bitbucket-pipelines.yml into mine, and I copied and pasted his composer.json, I ran the pipeline. Failed ❌
But I got this in the composer install log:
+ composer install --ignore-platform-reqs --no-scripts
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Package operations: 199 installs, 0 updates, 0 removals
- Installing kylekatarnls/update-helper (1.2.0): Downloading (connecting...)Downloading (0%) Downloading (100%)
- Installing ocramius/package-versions (1.4.2): Downloading (connecting...)Downloading (0%) Downloading (30%)Downloading (35%)Downloading (65%)Downloading (95%)Downloading (100%)
- Installing symfony/polyfill-ctype (v1.13.1): Downloading (connecting...)Downloading (0%) Downloading (100%)
So i figured it's b/c the composer.lock file is out of sync with composer.json, so I added composer update to my pipeline.. this loaded from cache! ✅but failed here ❌:
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 108 installs, 0 updates, 0 removals
- Installing ocramius/package-versions (1.4.2): Downloading (connecting...)Downloading (0%) Downloading (30%)Downloading (35%)Downloading (65%)Downloading (80%)Downloading (100%)
- Installing symfony/flex (v1.6.0): Downloading (connecting...)Downloading (100%)
Symfony operations: 1 recipe (4c6f09f5995a77b64f54dd80675d3bfe)
- Configuring symfony/flex (>=1.0): From github.com/symfony/recipes:master
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.0.*"
Prefetching 106 packages
- Downloading (0%) (5%) (10%) (16%) (21%) (31%) (36%) (41%) (47%) (52%) (57%) (65%) (70%) (75%) (80%) (85%) (90%) (95%) (100%)
Package operations: 106 installs, 0 updates, 0 removals
- Installing psr/container (1.0.0): Loading from cache
- Installing symfony/service-contracts (v2.0.1): Loading from cache
..
..
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!! Fatal Error: composer.lock was created for PHP version 7.2.9 or higher but the current PHP version is 7.1.32.
note: in my original composer.json file, i found this line
"config": {
..
"cache-dir": "~/.cache/composer",
},
so I removed that line, but that didn't help either.
Still digging (for the record this is what my composer.json looks like, i kept the cache-dir part in it for reference)
According to a question on the Bitbucket forums, this can happen if the docker image you are using is putting the downloaded files in a unusual position. According to the documentation about caches, the usual directory that is cached is ~/.composer/cache, while the docker file of the image uses /composer.
Please try to use the following configuration. It contains a custom cache (which needs a custom name!) that puts the customized composer folder in the cache:
pipelines:
branches:
develop:
- step:
caches:
- composer-custom
definitions:
caches:
composer-custom: /composer/cache
As you can see on https://bitbucket.org/haasenico/composer-cache/addon/pipelines/home#!/results/4, the cache is used and seems to work for my short example
To make this work I basically followed Nico Haase's answer, but I also had to do the following:
remove "cache-dir": "~/.cache/composer" from my composer.json
ensure that the cache file saved is in sync with whatever is going on in composer.json.. you cannot ask composer.json to load the dependencies from a cache file that has irrelevant content. To do this, I simply deleted all caches file and started again, it worked this time!
i'm working already with symfony 3, I've create a lot of project with it, so now i'm trying to create a project with symfony 4, but i can't when i type this command :
composer create-project symfony/skeleton my-project-symf-4
the project is created successfully, but the problem that is created with this version 3.4 instead of 4.2,
Installing symfony/skeleton (v3.4.22.1)
- Installing symfony/skeleton (v3.4.22.1): Downloading (100%)
Created project in my-project-symf-4
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 22 installs, 0 updates, 0 removals
- Installing symfony/flex (v1.1.8): Downloading (100%)
Prefetching 21 packages
- Downloading (100%)
- Installing psr/cache (1.0.1): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache
- Installing psr/log (1.1.0): Loading from cache
- Installing symfony/debug (v3.4.22): Loading from cache
- Installing symfony/console (v3.4.22): Loading from cache
- Installing symfony/dotenv (v3.4.22): Loading from cache
- Installing symfony/routing (v3.4.22): Loading from cache
- Installing symfony/http-foundation (v3.4.22): Loading from cache
- Installing symfony/event-dispatcher (v3.4.22): Loading from cache
- Installing symfony/http-kernel (v3.4.22): Loading from cache
- Installing symfony/finder (v3.4.22): Loading from cache
- Installing symfony/filesystem (v3.4.22): Loading from cache
- Installing symfony/dependency-injection (v3.4.22): Loading from cache
- Installing symfony/config (v3.4.22): Loading from cache
- Installing symfony/class-loader (v3.4.22): Loading from cache
- Installing symfony/polyfill-apcu (v1.10.0): Loading from cache
- Installing symfony/cache (v3.4.22): Loading from cache
- Installing symfony/framework-bundle (v3.4.22): Loading from cache
- Installing symfony/yaml (v3.4.22): Loading from cache
Generating autoload files
So as you can see the composer load all packages from cache.
I've try to clear composer cache like this:
$ composer clearcache
but without result, the problem still exist.
My PHP Version is 7.3.1
Can anyone help me to resolve that problem?
Try to pass the symfony version (4.2 for example) like that:
composer create-project symfony/skeleton:4.2 my-project-symf-4
Hope this helps!
If you installed symfony CLI in your system then you just run the below command with specifying version number
For Example to create a Symfony project with 4.4 version run following command
symfony new my_project_name --version=4.4
I'm using the acelaya/zf2-acqrcode package (v0.2.0) It requires "endroid/qrcode": ">=1.2.0", (meaning everything higher than or equal to 1.2.0)
Currently the latest version of the "endroid/qrcode" package = v3.2.12
The acelaya/zf2-acqrcode package (v0.2.0) uses a function that doesn't exist anymore in endroid/qrcode versions > 1.9.3
Is there any way I can tell composer not to install a version of the endroid/qrcode package higher than 1.9.3?
Yes you can restrict the package versions by using the ~ operator in composer.json. More Information on that can be found Here
Hope this helps.
Use the following to lock the endroid/qrcode dependency to 1.9.3. Sub dependencies will adhere to this and honour the fact you've locked acelaya/zf2-acqrcode.
Note: this will only fail when another dependency requires >1.9.3 of endroid/qrcode
{
"require": {
"endroid/qrcode": "1.9.3",
"acelaya/zf2-acqrcode": "^1.0"
}
}
Run the command following command:
/path/to/composer.phar require endroid/qrcode:1.9.3
Here's the output of the above required dependencies:
$ composer install
Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 18 installs, 0 updates, 0 removals
- Installing zendframework/zend-stdlib (3.2.0): Loading from cache
- Installing zendframework/zend-loader (2.6.0): Loading from cache
- Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
- Installing zendframework/zend-view (2.10.0): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing container-interop/container-interop (1.2.0): Loading from cache
- Installing zendframework/zend-servicemanager (3.3.2): Loading from cache
- Installing zendframework/zend-validator (2.10.2): Loading from cache
- Installing zendframework/zend-escaper (2.6.0): Loading from cache
- Installing zendframework/zend-uri (2.6.1): Loading from cache
- Installing zendframework/zend-http (2.8.0): Loading from cache
- Installing zendframework/zend-router (3.0.2): Loading from cache
- Installing zendframework/zend-config (3.2.0): Loading from cache
- Installing zendframework/zend-modulemanager (2.8.2): Loading from cache
- Installing zendframework/zend-mvc (3.1.1): Loading from cache
- Installing symfony/options-resolver (v3.4.11): Loading from cache
- Installing endroid/qrcode (1.9.3): Loading from cache
- Installing acelaya/zf2-acqrcode (v1.0.0): Loading from cache
I want to learn Symfony Framework but i can't run it.Composer latest version.And i use this command to install framework as Docs said.Than i use this command for start the server in "project/" folder but i get that error "Could not open input file: bin/console".
duhan#dbalci:/var/www$ composer create-project symfony/skeleton project
Installing symfony/skeleton (v4.0.5)
- Installing symfony/skeleton (v4.0.5): Loading from cache
Created project in project
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 21 installs, 0 updates, 0 removals
- Installing symfony/flex (v1.0.78): Loading from cache
- Installing symfony/polyfill-mbstring (v1.7.0): Loading from cache
- Installing symfony/console (v4.0.8): Loading from cache
- Installing symfony/routing (v4.0.8): Loading from cache
- Installing symfony/http-foundation (v4.0.8): Loading from cache
- Installing symfony/yaml (v4.0.8): Loading from cache
- Installing symfony/framework-bundle (v4.0.8): Loading from cache
- Installing symfony/http-kernel (v4.0.8): Loading from cache
- Installing symfony/event-dispatcher (v4.0.8): Loading from cache
- Installing psr/log (1.0.2): Loading from cache
- Installing symfony/debug (v4.0.8): Loading from cache
- Installing symfony/finder (v4.0.8): Loading from cache
- Installing symfony/filesystem (v4.0.8): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing symfony/dependency-injection (v4.0.8): Loading from cache
- Installing symfony/config (v4.0.8): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing symfony/cache (v4.0.8): Loading from cache
- Installing symfony/dotenv (v4.0.8): Loading from cache
Writing lock file
Generating autoload files
duhan#dbalci:/var/www$ cd project/
duhan#dbalci:/var/www/project$ php bin/console server:run
Could not open input file: bin/console
There is just "vendor/" folder but i seen in tutorials there is more.
"ls -l" output :
duhan#dbalci:/var/www/project$ ls -l
total 60
-rw-rw-r-- 1 duhan duhan 1231 Apr 13 13:30 composer.json
-rw-rw-r-- 1 duhan duhan 48230 Apr 13 13:30 composer.lock
-rw-rw-r-- 1 duhan duhan 3 Apr 13 13:30 symfony.lock
drwxrwxr-x 5 duhan duhan 4096 Apr 13 13:30 vendor
It seems like Composer hasn't fully executed the functionality in the symfony/flex plugin. The only reason I can think of that would cause this is if you've got plugins disabled globally (you can diagnose this by running composer config -l and seeing if it mentions no-plugins anywhere)
I can replicate your directory structure by running:
composer create-project symfony/skeleton project --no-plugins
cd project
composer install
This will create an empty symfony.lock file, but not unpack any of the installed Symfony recipes.
From here, you should be able to complete the installation by running
composer fix-recipes
in the project folder. This will finish unpacking all of the installed recipes, including creating the missing directory structure.
I'm trying to get Symfony in my Mac, so I installed symfony and composer in order to start developing, but when I create the project I have some problems:
composer create-project symfony/skeleton cost_management
Installing symfony/skeleton (v4.0.5)
- Installing symfony/skeleton (v4.0.5): Loading from cache
Created project in cost_management
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 21 installs, 0 updates, 0 removals
- Installing symfony/flex (v1.0.71): Loading from cache
- Installing symfony/polyfill-mbstring (v1.7.0): Loading from cache
- Installing symfony/console (v4.0.6): Loading from cache
- Installing symfony/routing (v4.0.6): Loading from cache
- Installing symfony/http-foundation (v4.0.6): Loading from cache
- Installing symfony/yaml (v4.0.6): Loading from cache
- Installing symfony/framework-bundle (v4.0.6): Loading from cache
- Installing symfony/http-kernel (v4.0.6): Loading from cache
- Installing symfony/event-dispatcher (v4.0.6): Loading from cache
- Installing psr/log (1.0.2): Loading from cache
- Installing symfony/debug (v4.0.6): Loading from cache
- Installing symfony/finder (v4.0.6): Loading from cache
- Installing symfony/filesystem (v4.0.6): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing symfony/dependency-injection (v4.0.6): Loading from cache
- Installing symfony/config (v4.0.6): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing symfony/cache (v4.0.6): Loading from cache
- Installing symfony/dotenv (v4.0.6): Loading from cache
Writing lock file
Generating autoload files
Symfony operations: 4 recipes (7c280e93acfad83db0b06dac8600cc2d)
- Configuring symfony/flex (>=1.0): From github.com/symfony/recipes:master
- Configuring symfony/framework-bundle (>=3.3): From github.com/symfony/recipes:master
- Configuring symfony/console (>=3.3): From github.com/symfony/recipes:master
- Configuring symfony/routing (>=4.0): From github.com/symfony/recipes:master
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!
!! Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "FileResource" from namespace "App".
!! Did you forget a "use" statement for "Symfony\Component\Config\Resource\FileResource"? in /Users/gate11/Desktop/cost_management/src/Kernel.php:39
!! Stack trace:
!! #0 /Users/gate11/Desktop/cost_management/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(80): App\Kernel->configureContainer(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\Config\Loader\DelegatingLoader))
!! #1 [internal function]: App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!! #2 /Users/gate11/Desktop/cost_management/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(38): call_user_func(Object(Closure), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!! #3 /Users/gate11/Desktop/cost_management/vendor/symfony/config/Loader/DelegatingLoader.php(40): Symfony\Component\DependencyInj in /Users/gate11/Desktop/cost_management/src/Kernel.php on line 39
!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "FileResource" from namespace "App".
!! Did you forget a "use" statement for "Symfony\Component\Config\Resource\FileResource"? in /Users/gate11/Desktop/cost_management/src/Kernel.php:39
!! Stack trace:
!! #0 /Users/gate11/Desktop/cost_management/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php(80): App\Kernel->configureContainer(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Object(Symfony\Component\Config\Loader\DelegatingLoader))
!! #1 [internal function]: App\Kernel->Symfony\Bundle\FrameworkBundle\Kernel\{closure}(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!! #2 /Users/gate11/Desktop/cost_management/vendor/symfony/dependency-injection/Loader/ClosureLoader.php(38): call_user_func(Object(Closure), Object(Symfony\Component\DependencyInjection\ContainerBuilder))
!! #3 /Users/gate11/Desktop/cost_management/vendor/symfony/config/Loader/DelegatingLoader.php(40): Symfony\Component\DependencyInj in /Users/gate11/Desktop/cost_management/src/Kernel.php on line 39
!!
I tried many ways to install it, I saw the commands in their website, so I did it but still having some problems installing it.
If someone knows what's wrong with it, or if I need something else, I'm hoping for your help.
Thanks.
Please replace composer create-project symfony/skeleton cost_management with composer create-project symfony/website-skeleton cost_management
**OR**
You could install and setup Symfony4 application on Ubuntu with PHP7.2 by these steps execute through temminal:
composer create-project symfony/website-skeleton cost_management
cd cost_management
php -S 127.0.0.1:8000 -t public
ctrl + c to exit server run composer install
sudo chmod 777 -R var/cache/ var/log/
now again php -S 127.0.0.1:8000 -t public
Now you can check on your browser by this http://localhost:8000/ or directly you can access without server run by http://localhost/project_directory/public/index.php
Note:-
1. By default symfony 4 is set to dev environment, but you could set
your environment by setting $_SERVER['APP_ENV']
2. If it's working proper then you will see a 404 error message and profiler in bottom because it's by default set to dev mode.
3. To see something you need to create your first controller by following documents Symfony 4 create your first page
Just add this:
use Symfony\Component\Config\Resource\FileResource;
to the top of your src/Kernel.php, it was missed for some reason.
After that, you can continue with composer install