hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Symfony Cache with Database

The Symfony Cache component has a large number of possible adapters for cached information.

For caching in the database, you can use the following PdoAdapter for Doctrine and configure the following dimensions:

#config/packages/framework.yaml
framework:
    cache:
        pools:
            app:
                adapter: AppCache
#config/services.yaml
AppCache:
  class: Symfony\Component\Cache\Adapter\PdoAdapter
  arguments:
    - '@doctrine.dbal.default_connection'

Symfony thus generates a database table within the default database connection for the cache entries.

This has particularly performance gains and is clearer compared to the default file system variant. This is especially recommended for a Docker environment, because the slow file system does not need to be diluted.

hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Symfony 5 Exception “The annotation was never imported.”

One reason for the error message may be, that it is actually an annotation, that is invalid, but is in the vendor code. Then you should ignore them.

Error message:

Doctrine\Common\Annotations\AnnotationException : [Semantical Error] The annotation "@suppress" in method Monolog\Formatter\LineFormatter::normalizeException() was never imported. Did you maybe forget to add a "use" statement for this annotation?

If you ignore the annotation with the static call to in the config/bootstrap.php:

AnnotationReader::addGlobalIgnoredName('suppress');

 

hard mistakes - please write a commentsome mistakesokgoodvery good 3.00 of 500 (1 Users)
Loading ... Loading ...

Protractor configuration Headless Chrome and Firefox

To run Selenium tests in Firefox and Chrome in Headless mode with Protractor, the following configuraton can be used in the protractor.conf:

exports.config = {
....
  multiCapabilities: [
    {
      browserName: 'chrome',
      chromeOptions: {
        'args': ['--headless']
      },
    },
    {
      browserName: 'firefox',
      firefoxOptions: {
        args: ['--headless']
      },
      'moz:firefoxOptions': {
        args: ['--headless']
      }
    },
  ],
...
};
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Secure Jenkins with self-signed SSL certificate

So that Jenkins can only be reached via HTTPS on Linux, first you have to create an SSL certificate in the folder:

mkdir /var/lib/jenkins/ssl_cert/
cd /var/lib/jenkins/ssl_cert/

openssl req -newkey rsa:2048 -x509 -keyout cakey.pem -out cacert.pem -days 3650

Then you can convert this certificate for the Java Key Store:

openssl pkcs12 -export -in cacert.pem -inkey cakey.pem -out identity.p12 -name jenkins
keytool -importkeystore -destkeystore identity.jks  -srckeystore identity.p12 -srcstoretype PKCS12

and import into the Java Key Store:

keytool -import -file cacert.pem -keystore trust.jks

In the end, only the Config has to be adjusted:

sudo vi /etc/sysconfig/jenkins

with the values:

JENKINS_PORT="-1"

JENKINS_HTTPS_PORT="8443"

JENKINS_HTTPS_KEYSTORE="/var/lib/jenkins/ssl_cert/identity.jks"

JENKINS_HTTPS_KEYSTORE_PASSWORD="YOUR_PASSWORD_HERE"

JENKINS_HTTPS_LISTEN_ADDRESS="0.0.0.0"

And the service will be restarted:

chown -R jenkins: /var/lib/jenkins/ssl_cert/*
chmod 600 /var/lib/jenkins/ssl_cert/*

sudo systemctl restart jenkins
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Create your own metrics in AWS Cloudwatch

To use CloudWatch Create your own metrics, by e.g.. alarm and to operate monitoring with the data of the application, can you use the aws-php-sdk use the following code:

 $client = new CloudWatchClient([
        'region' => 'eu-central-1',
        'version' => '2010-08-01',
        'credentials' => [
            'key'    => 'xxx',
            'secret' => 'xxx
        ],
    ]);
}
$result = $this->client->putMetricData(array(

    'Namespace' => 'MyProject',
    'MetricData' => array(
        array(
            'MetricName' => 'MyMetric,
            'Timestamp' => time(),
            'Value' => 1,
            'Unit' => 'Count',
            'Dimensions' => array(
                array(
                    'Name' => 'Environment',
                    'Value' => 'test',
                ),
            ),
        )
    )
));
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Use Docker Shell Alias on Linux

In order to use the Linux Shell to use the usual aliases such as Ll for ls -lh to use, you have to use the following trick:

Since the login via sh is not a Linux login shell, the alias definitions are /etc/profile.d not loaded at login.

Solution:

Enough, deal with Sh –login in the container, then the alias definitions are available.

hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

DockerFile PHP with XDebug and Amazon Linux 2

A DockerFile for a PHP 7.2. Environment with XDebug for a Symfony 4 Environment on Amazon Linux 2:

FROM amazonlinux:2.0.20190823.1

RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# install php
RUN amazon-linux-extras install -y php7.2
RUN yum install -y php-devel.x86_64 php-xml.x86_64 php-pecl-zip.x86_64  php-intl.x86_64

#install xdebug
RUN yum install -y gcc make
RUN yum install -y php-pear.noarch
RUN pecl install xdebug
RUN echo 'zend_extension=/usr/lib64/php/modules/xdebug.so' >> /etc/php.ini
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Docker Xdebug remote_host setzen in Toolbox für PHPStorm

To debug with Xdebug and PHPStorm in the Docker Container, but gets the error message:

Connection was not established. Probably 'xdebug.remote_host=docker.for.win.localhost' is incorrect

this is due to the, that Docker in the Toolbox variant for Windows has the placeholder docker.for.win.localhost not filled. So the IP of the PHPStorm computer has to be set manually.

To do this, you manually set the value of xdebug.remote_host to 192.168.99.1 (the IP Docker sets for the host, can varnise) cli interpreter options: