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

PHP-XMLReader for very large files example

Around with PHP to parse large XML files, do you want to use a SAX parser, the XML reads files from top to bottom and not transforming into an object. This is the XMLReader PHP.

An example:

$data = new Data();
$reader = new \XMLReader();
$reader->open($file);

while ($reader->read()) {
    if ($reader->nodeType == \XMLReader::ELEMENT) {
        switch ($reader->name) {
            case "tagName1" :
                $node = new \SimpleXMLElement($reader->readOuterXML());
                $attributes = $node->attributes();
                $entity = new Entity();
                $entity->setId($attributes['id']);
                $entity->setName($attributes['name']);
                $entity->setCode($attributes['code']);
                $data->addEntity($entity);

                break;

            case  "tagName2":
                $node = new \SimpleXMLElement($reader->readOuterXML());
                $attributes = $node->attributes();
                $entity = new OtherEntity();
                $entity->setId($attributes['id']);
                $entity->setName($attributes['name']);
                $entity->setCode($attributes['code']);
                $data->addOtherEntity($entity);

                break;
        }
    }
}
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Microsoft IIS REST API allow by PUT, DELETE

To the IIS 7.5 all HTTP verbs like PUT, POST, DELETE and PATCH to enable, need to disable the following modules and handlers in the web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <modules>
         <remove name="WebDAVModule" />
      </modules>
        <handlers>
            <remove name="WebDAV" />
            <remove name="OPTIONSVerbHandler" />
            <remove name="TRACEVerbHandler" />
        </handlers>
    </system.webServer>
</configuration>
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Microsoft IIS SSL certificate create for localhost for chrome 60 with SAN

To create a certificate for IIS under IIS, should you create a SSL certificate with openssl (comes with GIT in C:\Program FilesGitusrbin).

With the two commands, you can create a .pfx file, also see chrome 60 He runs on option chrome://flags/#allow-insecure-localhost.

openssl req  -newkey rsa:2048 -x509   -nodes -keyout server.key  -new  -out server.crt  -subj /CN=localhost  -reqexts SAN -extensions SAN  -config openssl.cnf -sha256 -days 36500
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt

You need a configuration file OpenSSL.cnf: more…

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

Twig extension to sort of entities by DateTime property

If one wants to sort a collection of doctrine in the template after a time stamp (createdAt the example), before actually make this.

If this is not possible, e.g.. in the Sonata Admin Bundle, then you can use this twig extension:

{% foo| sortByCreatedAt('asc') %}

Twig extension code:

<?php

namespace App\Twig;

use App\Entity\Tag;
use Doctrine\ORM\PersistentCollection;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

class AppExtension extends AbstractExtension
{
    public function getFilters()
    {
        return array(
            new TwigFilter('sortByCreatedAt', array($this, 'sortByCreatedAt')),
        );
    }

    /**
     * @param PersistentCollection $objects
     * @return mixed
     */
    public function sortByCreatedAt($objects, $direction = 'asc')
    {
        $objects = $objects->toArray();
        usort($objects, function ($a, $b) use($direction) {
            if ($direction === 'asc') {
                return $a->getCreatedAt() >  $b->getCreatedAt();
            } elseif ($direction === 'desc') {
                return $a->getCreatedAt() <  $b->getCreatedAt();
            } else {
                throw new \Exception('unknown sort direction');
            }

        });
        return $objects;
    }
}
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

JavaScript debugging on the console with console.table()

The new JavaScript method Console.table() is very hilfgreich, to represent objects and arrays on the console.

Example:

var data = [
        {"id": "Open"},
        {"id": "OpenNew", "label": "Open New"},
        null,
        {"id": "ZoomIn", "label": "Zoom In"},
        {"id": "ZoomOut", "label": "Zoom Out"},
        {"id": "OriginalView", "label": "Original View"},
        null,
        {"id": "Quality"},
        {"id": "Pause"},
        {"id": "Mute"},
        null,
        {"id": "Find", "label": "Find..."},
        {"id": "FindAgain", "label": "Find Again"},
        {"id": "Copy"},
        {"id": "CopyAgain", "label": "Copy Again"},
        {"id": "CopySVG", "label": "Copy SVG"},
        {"id": "ViewSVG", "label": "View SVG"},
        {"id": "ViewSource", "label": "View Source"},
        {"id": "SaveAs", "label": "Save As"},
        null,
        {"id": "Help"},
        {"id": "About", "label": "About Adobe CVG Viewer..."}
    ];

console.table(data);

Produces the following output in the developer tools in the chrome:

console-table

 

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

Angular 5 URL without index.html

At an angular application you must call by default the index.html, Thus starts the application on an Apache Web server. This also without / index.html with the domain alone only (www.foo.de) funktioneirt, do you set this:

1. Create a .htaccess file in src/.htaccess with the content:

DirectoryIndex index.html

2. Change the base URL in the src/index.html

<base href="">

3. GGF. Add .htaccess to the build process in the .angular cli.json

"apps": [
  {
    "assets": [
      "assets",
      "favicon.ico",
      ".htaccess"
    ],

 

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

Strato und MySQL: General error: 1709 Index column size too large. The maximum column size is 767 bytes.

A customer following error message was shown to me, When I tried the database have symfony to create:

General error: 1709 Index column size too large. The maximum column size is 767 bytes.

This is because, the Strato strange setting in their managed hosting packages such as z.B. has the STRATO PowerWeb. Strato unfortunately won't change this setting, but you can in symfony in the doctrine.yaml (config.YAML) change the charset, Symfony works well on a Strato Server:

doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.6'
        charset: utf8
        default_table_options:
            charset: utf8
            collate: utf8_general_ci
hard mistakes - please write a commentsome mistakesokgoodvery good
Loading ... Loading ...

Symfony security passwords hash with the PasswordEncoder

The PasswordEncoder the symfony framework secure hashes of passwords in the database is very well suitable also in future to save and configure Central.

The SecurityBundle must if necessary. to be installed:

composer require symfony/security-bundle

Putting this in the security.yaml, you want to use what hashing algorithm for which entity:

security:
    encoders:
        App\Entity\User: bcrypt

The entity must implement the UserInterface: more…