Web + Mobile Blog / Berlin http://sebastianviereck.de/en/ PHP Freelancer Thu, 14 May 2020 06:59:56 +0000 en hourly 1 http://wordpress.org/?v=3.5.1 Symfony Cache with Database http://sebastianviereck.de/en/symfony-cache-with-database/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/symfony-cache-with-database/#comments Thu, 14 May 2020 06:59:56 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4166-en Continue reading ]]> The Symfony Cache component besitzt eine große Zahl von möglichen Adaptern zum Cachen von Informationen.

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'

Damit erzeugt Symfony eine Datenbank Tabelle innerhalb der default Datenbank Verbindung für die Cache Einträge.

This has particularly performance gains and is clearer compared to the default file system variant. This is especially recommended for a Docker environment, weil das langsame Dateisystem nicht verwnedet werden muss.

]]>
http://sebastianviereck.de/en/symfony-cache-with-database/feed/ 0
Symfony 5 Exception “The annotation was never imported.” http://sebastianviereck.de/en/symfony-5-exception-the-annotation-imported/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/symfony-5-exception-the-annotation-imported/#comments Thu, 26 Sea 2020 09:51:05 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4157-en Continue reading ]]> One reason for the error message may be, that it is actually an annotation, that is invalid, but is in the vendor code. Dann sollte man diese ignorieren.

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');

 

]]>
http://sebastianviereck.de/en/symfony-5-exception-the-annotation-imported/feed/ 0
Protractor configuration Headless Chrome and Firefox http://sebastianviereck.de/en/protractor-configuration-headless-chrome-and-firefox/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/protractor-configuration-headless-chrome-and-firefox/#comments Thu, 06 Feb 2020 16:02:02 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4144-en Continue reading ]]> 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']
      }
    },
  ],
...
};
]]>
http://sebastianviereck.de/en/protractor-configuration-headless-chrome-and-firefox/feed/ 0
Secure Jenkins with self-signed SSL certificate http://sebastianviereck.de/en/secure-jenkins-with-self-signed-ssl-certificate/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/secure-jenkins-with-self-signed-ssl-certificate/#comments Tue, 04 Feb 2020 12:46:44 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4141-en Continue reading ]]> 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
]]>
http://sebastianviereck.de/en/secure-jenkins-with-self-signed-ssl-certificate/feed/ 0
Jenkins Ant build failed: exec returned 255 http://sebastianviereck.de/en/jenkins-ant-build-failed-exec-returned-255/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/jenkins-ant-build-failed-exec-returned-255/#comments Mon, 03 Feb 2020 16:16:43 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4137-en If the Ant Build in the Jenkins server fails with the very untelling error message:

build.XML:103: exec returned: 255

then this may be due to, dass nicht genug RAM zur Verfügung steht.

 

]]>
http://sebastianviereck.de/en/jenkins-ant-build-failed-exec-returned-255/feed/ 0
Create your own metrics in AWS Cloudwatch http://sebastianviereck.de/en/php-create-your-own-metrics-aws-cloudwatch/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/php-create-your-own-metrics-aws-cloudwatch/#comments Thu, 19 Dec 2019 16:12:20 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4132-en Continue reading ]]> 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',
                ),
            ),
        )
    )
));
]]>
http://sebastianviereck.de/en/php-create-your-own-metrics-aws-cloudwatch/feed/ 0
Docker Image build suddenly no longer an Internet connection http://sebastianviereck.de/en/docker-image-build-suddenly-no-longer-an-internet-connection/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/docker-image-build-suddenly-no-longer-an-internet-connection/#comments Thu, 12 Dec 2019 16:18:32 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4128-en If you can't install packs on a build, you can try, restart the docker-machine:

docker-machine restart
]]>
http://sebastianviereck.de/en/docker-image-build-suddenly-no-longer-an-internet-connection/feed/ 0
Use Docker Shell Alias on Linux http://sebastianviereck.de/en/use-docker-shell-alias-under-linux/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/use-docker-shell-alias-under-linux/#comments Thu, 12 Dec 2019 16:13:34 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4126-en Continue reading ]]> 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 nicht geladen beim Login.

Solution:

Enough, deal with Sh –login in the container, dann stehen die Alias Definitionen zur Verfügung.

]]>
http://sebastianviereck.de/en/use-docker-shell-alias-under-linux/feed/ 0
DockerFile PHP with XDebug and Amazon Linux 2 http://sebastianviereck.de/en/dockerfile-php-with-xdebug-and-amazon-linux-2/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/dockerfile-php-with-xdebug-and-amazon-linux-2/#comments Thu, 12 Dec 2019 13:33:48 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4122-en Continue reading ]]> 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
]]>
http://sebastianviereck.de/en/dockerfile-php-with-xdebug-and-amazon-linux-2/feed/ 0
Docker Xdebug remote_host setzen in Toolbox für PHPStorm http://sebastianviereck.de/en/docker-xdebug-remote_host-setzen-toolbox-fuer-phpstorm/?utm_source=rss&utm_medium=rss& http://sebastianviereck.de/en/docker-xdebug-remote_host-setzen-toolbox-fuer-phpstorm/#comments Thu, 12 Dec 2019 10:55:26 +0000 Sebastian Viereck http://sebastianviereck.de/?p=4119-en Continue reading ]]> 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. Es muss also die IP des PHPStorm Rechners manuell gesetzt werden.

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:

 

]]>
http://sebastianviereck.de/en/docker-xdebug-remote_host-setzen-toolbox-fuer-phpstorm/feed/ 0