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

Travis CI: No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

The very cryptic error message in Travis CI.:

No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

handlet's is a problem with incorrect indentation in the travis.yml file:

matrix:
  include:
    - php: 5.6
      env:
        - SYMFONY_VERSION='3.4.*'

A space in the line – SYMFONY_VERSION = ’ 3.4. *.’ and this little revealing error.

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

GitHub continuous integration and CodeCoverage Travis CI

For my public GitHub project Entity to rest bundle for symfony, Did I Travis CI, a service of a company from Berlin/Friedrichshain, used for continuous integration, and am fully excited. I had one .Travis.yml create and join me free with my Github account and I can now with just a few hand movements using Travis CI.:

  • Testing of different PHP versions
  • Test versions of different symfony
  • Markup on GitHub on the progress of the tests: Build:success/failed
  • automatic email notification of the result after each pull request

Now appears a fancy graphics and informs about the current build status:

travis_github_ci

The Result of the build can you watch on the travis ci Web page.

Note: For public GitHub repositories is the service free, You must pay for private repositories.

The CodeCoverage can also view and calculate, can you register for free at one of the two providers and must only the CodeCoverage generation in its .Travis.yml triggers.

https://codecov.IO Example project

https://coveralls.IO Example project

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

Symfony entity to REST API bundle released

In my current project I program with symfony 3 a REST API and have made various Bundlen a REST of suite created for symfony 3 created, which includes the following components:

  • API documentation of incl sandbox testing – without programming knowledge, the code can be removed and be tried
  • the documentation is automatically generated from the properties of the entities, no additional effort is necessary
  • the validation of the parameter is automatically performed by the entities, no additional effort is necessary
  • a search is automatically included, the relations of entities are also searchable
  • CRUD functionality: GET, CREATE, UPDATE, DELETE of an entity is already implemented and can be extended
  • simple testing: Integration tests are easily buildable / Templates are provided
  • a Demo REST service project with the demo code is ready
  • detailed Documentation
  • simple installation via composer: composer require sebvie/rest suite bundle

If you are interested I can like to integrate the bundle to your project or work: Contact.

 

 

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

PHP: Parse Error: syntax error, unexpected ‘:’, expecting ‘;’ or ‘{‘

The very cryptic error message

Parse Error: syntax error, unexpected ':', expecting ';' or '{'

It is in most cases a PHP7 incompatibility.

The code contains a language feature, What is only available at PHP7:

Return type definitions (Definition of the return value). Example:

function myFuntion($input): array
{
    return ['foo'];
}

This can strength enable, the function must return an array, otherwise an TypeErrror is thrown.

To make the code less PHP version running, muss man die Return Type Definition entfernen:

function myFuntion($input)
{
    return ['foo'];
}

Special case: composer more…

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

Download symfony static fixtures when loading an integration tests in PHPUnit

Static function setUpBeforeClass() by PHPunit can be done once before which load tests in a class of fixtures and reset the database:

class MyTestCase extends WebTestCase
{
    use FixtureLoadTrait;
 /**
 * @return void
 */
 public static function setUpBeforeClass()
 {

     $fixtures = [
         new TriggerConditionFixture()
     ];
     self::rebuildDataBase($fixtures);
 }

The fixtures can be easily download with the trait and the database is flushed:

<?php

namespace Tests\Integration;

use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Tests\Fixture\BackendBundle\DataFixtures\ORM\LoginFixture;

trait FixtureLoadTrait
{

    /**
     * @param array $fixtures
     *
     * @return void
     */
    protected static function rebuildDataBase(array $fixtures)
    {
        self::bootKernel();
        $fixtureLoader = new ContainerAwareLoader(
            self::$kernel->getContainer()
        );
        foreach($fixtures as $fixture){
            $fixtureLoader->addFixture($fixture);
        }
        $fixtureLoader->addFixture(new LoginFixture());
        self::getFixtureExecutor()->execute($fixtureLoader->getFixtures());
    }

    /**
     * @return ORMExecutor
     */
    protected static function getFixtureExecutor()
    {
        /** @var \Doctrine\ORM\EntityManager $entityManager */
        $entityManager = self::$kernel->getContainer()
            ->get('doctrine')
            ->getManager();

        return new ORMExecutor(
            $entityManager,
            new ORMPurger($entityManager, ['user'])
        );
    }

    /**
     * @return ContainerAwareLoader
     */
    protected static function getFixtureLoader()
    {
        return new ContainerAwareLoader(
            self::$kernel->getContainer()
        );
    }
}
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

PHPStorm replace regex across multiple lines

To write a regex in PHPStorm about multiple Zeieln, can I use this example regex:

\n.+ \* .*statusCodes([^}])+.+

Through the negation: ([^}])+ used by the regex all lines up to the next closing brace.

A text, the complete match would be is (the items from the regex are marked):

       *    statusCodes={
     *          200="Returned on %Entity% get",
     *          400="Returned when the parameters are wrong",
     *          404="Returned when %Entity% not found",
     *          405="Returned when method is wrong (GET|POST|PUT|..)",
     *          500="Returned when a exception is thrown"
     *    }

Another possibility for multiline PHP comments (/** */) is this regex:

.*\/\*[^\/]+\/\s
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

PHP queue systems compared

A comparison of various queue systems for use in a PHP application.

Apache ActiveMQ

The Apache project ActiveMQ offers:

  • relatively few clients in different languages in Java, C, C , C#, Ruby, Perl, Python, PHP
  • the communication of PHP with ActiveMQ using the STOMP protocol
  • a STOMP/ActiveMQ client offers STOMP-php
  • Enterprise usage possible
  • Apache project – Further development is safe
  • Open source
  • rather out of date

RabbitMQ

RabbitMQ is a modern, widespread queue system.

  • large selection of Clients
  • for PHP which is PHP-amqplib Client most widely spread
  • to be simpler and more modern
  • very good Documentation
  • Enterprise usage possible
  • Open source

Apache Kafka

Apache Kafka is the most advanced queue system, the special feature

  • extreme performance through the use of streams
  • PHP clients available: PHP-rdkafka
  • Enterprise usage possible
  • very good Documentation
  • Apache project – Further development is safe
  • Open source

Conclusion:

Due to the simple handling, I would recommend for most tasks RabbitMQ. For performance-critical applications Apache Kafka is best suited.

Can be found on an overview of other messaging queues Wikipedia.