I'm trying to deploy a PHP web application using Magallanes.
This is my actual task config:
tasks:
pre-deploy:
- composer/install
on-deploy:
- filesystem/link-shared-files:
linked_folders:
- web/fileadmin
- web/uploads
- web/typo3temp
- web/typo3conf/l10n
post-release:
- general/manually:
- vendor/bin/typo3cms install:fixfolderstructure
- vendor/bin/typo3cms install:generatepackagestates --activate-default=true
- vendor/bin/typo3cms cache:flush true
- vendor/bin/typo3cms database:updateschema "*.add,*.change"
- vendor/bin/typo3cms cache:warmup
post-deploy:
While using:
pre-deploy:
- composer/install
Composer will always be called with composer install --dev. Is there a way to call composer with --no-dev instead of --dev?
PS: I already tried - composer/install --no-dev, which generates the following error:
Starting Pre-Deployment tasks:
Task "Composer/installNoDev" not found.
Update
Because I needed some more parameters, I used general/manually. My solution is now:
tasks:
pre-deploy:
- general/manually:
- php7.0 /usr/local/bin/composer install --no-dev --no-progress --optimize-autoloader
But on the other hand my, original question was something different. So Chris's answere seems to be correct.
I think this will work:
pre-deploy:
- composer/install: {dev: false}
I couldn't find this in the documentation, but the source references a 'dev' parameter that seems to control --dev / --no-dev:
public function run()
{
$dev = $this->getParameter('dev', true);
return $this->runCommand($this->getComposerCmd() . ' install' . ($dev ? ' --dev' : ' --no-dev'));
}
The documentation is a bit more helpful about setting parameters, but I'm not sure if it will correctly read false as a Boolean value.
Related
i hope you are doing well, so my problem is that i cannot run the artisan test command
whenever i run the command php artisan test i get the following error
RuntimeException
Running Collision ^5.0 artisan test command requires Laravel ^8.0.
at D:\php-files\behzad-thingi\vendor\nunomaduro\collision\src\Adapters\Laravel\Commands\TestCommand.php:71
67▕ }
68▕
69▕ // #phpstan-ignore-next-line
70▕ if ((int) \Illuminate\Foundation\Application::VERSION[0] < 8) {
➜ 71▕ throw new RuntimeException('Running Collision ^5.0 artisan test command requires Laravel ^8.0.');
72▕ }
73▕
74▕ $options = array_slice($_SERVER['argv'], $this->option('without-tty') ? 3 : 2);
75▕
honestly i didint test that the command worked before, since i upgraded the dependencies to use pestphp and followed their installation steps here. thanks for your answer.
this was an issue with pestphp versioning, as explained in this here. i just had to replace the version of pestphp and collision from
"nunomaduro/collision": "v5.0.0-BETA3",
"pestphp/pest": "^0.2.3",
to
"nunomaduro/collision": "5.0.0-BETA2",
"pestphp/pest": "0.2.1",
I am investigating on how I can create an AWS lambda in php using the bref library
Therefore, according to documentation I set up the environment with the following command cocktail:
sudo -H npm install -g serverless
composer require bref/bref
Then using the following command created my first php lambda:
vendor/bin/bref init
And I selected the first option PHP Function provided by default. Creating the following creating an index.php file:
declare(strict_types=1);
require __DIR__.'/vendor/autoload.php';
lambda(function ($event) {
return 'Hello ' . ($event['name'] ?? 'world');
});
Then I changed my serverless.yml into that:
service: app
provider:
name: aws
region: eu-central-1
runtime: provided
stage: ${opt:stage,'local'}
package:
exclude:
- '.gitignore'
plugins:
- ./vendor/bref/bref
functions:
dummy:
handler: index.php
name: Dummy-${self:provider.stage}
description: 'Dummy Lambda'
layers:
- ${bref:layer.php-73}
And I try to launch it via the following command:
sls invoke local --stage=local --docker --function dummy
But I get the following error:
{"errorType":"exitError","errorMessage":"RequestId: 6403ebee-13b6-179f-78cb-41cb2f517460 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]"}
Therefore, I want to ask why I am unable to run my lambda localy?
Since this question is getting a lot of views, I recommend to have a look at the Bref documentation:
Local development for PHP functions
That involves using the bref local CLI command instead of serverless invoke local:
$ vendor/bin/bref local hello
Hello world
# With JSON event data
$ vendor/bin/bref local hello '{"name": "Jane"}'
Hello Jane
# With JSON in a file
$ vendor/bin/bref local hello --file=event.json
Hello Jane
On my local, clearing cache before invoking lambda worked fine, I'm using linux / ubuntu
docker system prune --all
sudo apt-get autoremove
sudo apt-get clean
sudo apt-get autoclean
sudo rm -rf ~/.cache/
sudo rm -rf /var/cache/
It is a known bug for bref. It can be solved via providing the layer manually on your function in serverless.yml. So the functions section at serverless.yml should change from:
functions:
dummy:
handler: index.php
name: Dummy-${self:provider.stage}
description: 'Dummy Lambda'
layers:
- ${bref:layer.php-73}
Into:
functions:
dummy:
handler: index.php
name: Dummy-${self:provider.stage}
description: 'Dummy Lambda'
layers:
- 'arn:aws:lambda:eu-central-1:209497400698:layer:php-73:15'
The reason why is that ${bref:layer.php-73} cannot be resolved into a php layer. Therefore, you need to provide manually the arn for the lambda layer.
Keep in mind that the arn comes into various "versions" that is being inidcated from the last number in the arn seperated with :. So in the arn
arn:aws:lambda:eu-central-1:209497400698:layer:php-73:15
Indicated that the layer is in version "15" whitch is thje latest at the moment of the answer. The next one logically should be the:
arn:aws:lambda:eu-central-1:209497400698:layer:php-73:16
I'm creating a Symfony 3.4 application.
Then I started to write some tests, which totally pass locally :
/**
* Two steps :
* 1) Checks if page goes on 200 status
* 2) Posts sample datas
*/
public function testDistanceAmongSequencesAction()
{
/**
* 1 - Access to the page OK
*/
$this->client->request('GET', '/minitools/distance-among-sequences');
static::assertEquals(200, $this->client->getResponse()->getStatusCode());
}
But when I push my code and execute it with Travis CI, it fails automatically : 3) MinitoolsBundleTest\Controller\MinitoolsControllerTest::testDistanceAmongSequencesAction
Failed asserting that 500 matches expected 200.
He is my .travis.yml file :
language: php
sudo: required
dist: trusty
php:
- '7.1.16'
services:
- mysql
script:
- composer self-update
- composer install --no-interaction --no-suggest
- bin/console server:run &
- vendor/bin/phpunit
The PHP version is the same as mine. I think the VM Travis can't access to y path, but why ? Thank you for your help !
OK, in my controller I called the TWIG templates using # annotation, and Travis doesn't understand it. So I modified each call and moved the TWIG into app/ressources. Thanks.
I am trying to integrate sonarcloud with Bitbucket pipeline. I have a simple test project with single file named index.php consisting few lines.
I am exactly not sure what method should I follow.
I have created sonar-project.properties files that consists following lines.
sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarcloud.io/dashboard?id=first_ftp
sonar.projectKey=first_ftp
Here is my yml file
image: aariacarterweir/lamp-gitftp:latest
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly
definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- node
- sonar
script:
- npm install --quiet
- npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox
- pipe: sonarsource/sonarcloud-scan:0.1.5
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/testing/**,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info'
When I check into sonarcloud website, It tells
The main branch has no lines of code
Can anybody help me how to configure properly sonarcloud with bitbucket for php project.
I've had the same issue - in my case it was because of the name of the project - it was called ---------Test, and apparently, by default, Sonar will treat that as a test assembly and will exclude it from analysis.
Before running code analysis in bitbucket pipelines, you would have to first manually run analysis(only once). By following below steps.
Created new project with appengine-starter-symfony-project (https://github.com/GoogleCloudPlatform/appengine-symfony-starter-project) and tried to run app/server as follows:
composer run-script server --timeout=0
Error recived:
// Clearing the cache for the dev environment with debug
// false
[Symfony\Component\Cache\Exception\CacheException]
Memcached >= 2.2.0 is required
Running PHP Version 7.2.8 on Xampp (Win 10) and cant see a php_memcache in ext folder.
Indeed, this is the expected behavior. If you take a look inside of config.yml you will see the following:
services:
memcache:
class: Memcache
session.handler.memcache:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler
arguments:
- "#memcache"
- { prefix: ~, expiretime: ~ }
Basically, you cache is dependent on Memchace. You can either tweak around and switch to some other vendor or install the appropriate DLL.
Hope this helps a bit...