Skip to content

Instantly share code, notes, and snippets.

@botris
botris / BulkUpdateController.php
Last active June 4, 2021 10:10
Update many entities with API Platform
<?php
class BulkUpdateController
{
private EntityWithManyProperties $entityWithManyProperties;
public function __construct(EntityWithManyProperties $entityWithManyProperties)
{
$this->entityWithManyProperties = $entityWithManyProperties;
}
@botris
botris / .env.local
Created September 18, 2020 09:52
Drupal/legacy table to Symfony Doctrine entity
DATABASE_URL=mysql://db:db@localhost/db?sslmode=disable&charset=utf8mb4&serverVersion=5.7
DATABASE_DRUPAL_URL=mysql://db:db@localhost/legacy?sslmode=disable&charset=utf8mb4&serverVersion=5.7
@botris
botris / entity.php
Created September 10, 2020 11:08
API Platform - handle 2 endpoints on the same entity
<?php
/**
* @ApiResource(
* itemOperations={
* "get"={
* "path"="/entity/{id}",
* "openapi_context" = {
* "parameters" = {
* {
@botris
botris / README.txt
Last active January 8, 2019 10:44
Ubuntu 18.10 switch php7.1 and php7.2
ATM php7.2 is current to Ubuntu.
Add php7.1 through:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
sudo apt-get install php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-dev php7.1-curl php7.1-xml
Switch with script
@botris
botris / install.md
Last active October 15, 2018 09:38
Install Contenta.

Installing https://www.contentacms.org/ on OS X.

Check current composer version

composer --version

If lower then 1.7 update:

composer self-update
@botris
botris / test_mysql.md
Created March 2, 2018 19:12
Testing MySQL speed on OS X
  • Install sysbench:
brew install sysbench
  • Create a new database called "dbtest"
  • Find the test file:
mdfind oltp_read_only.lua
  • Prepare test:
@botris
botris / gist:0ce3477e0f129d98604d
Created February 3, 2015 11:56
Get table sizes of MySQL DB, sorted by biggest to smallest
SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "DATABASENAME"
ORDER BY (data_length + index_length) DESC;
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
@botris
botris / gist:9ec9cb7023ebfd4c3551
Created November 28, 2014 17:49
Drupal to Drupal migrate, migrate associated terms
<?php
/*
* Extending DrupalNode5Migration (or 6) migrating the correct terms
* - Add the source migration and source tid
* - Declare default value
*/
$this->addFieldMapping('field_tags', '3')
->sourceMigration('Tags');
$this->addFieldMapping('field_tags:source_type')
->defaultValue('tid');