Discuss your project

PartITech blog

Technology blog

Technical analysis, practical guides and field experience to build, modernize and maintain sustainable applications.

232 articles Page 12

Sonata Admin: DataMapper and autowiring

If you have a specific need to transform data between the form and the recording of your entity and think that this transformation code should be located in a service because it makes more sense, you can use the dataMapper by utilizing the dependency injection provided by Symfony. But how to implement it? A small reminder about the DataMapper. If we agree with the official Symfony documentation regarding DataMapper and DataTransformer, a dataMapper has the responsibility to read and write an ...

SF6 / Sonata 5: Managing a OneToMany interface in a CRUD with Sonata's CollectionType

In this example, we will take the concrete case of a simple interface that includes multiple elements. We have chosen to use a "Projects" table in which we will assign documents. Therefore, for a project, we can assign several documents. And to facilitate administration, we will ensure that we can manage our nested interface directly within the edit view of our project.We need to create the schema. Firstly, we import our current schema into MysqlWorbench usi...

PHP FFI: using a Kotlin Multiplatform library — part 4

With Stéphane Péchard https://www.linkedin.com/in/stephanepechard/, Android expert and KMP guru, we wondered if developing an algorithm under KMP and executing it directly in PHP would be feasible. The specifications were simple: the Android dev (Stéphane) provides me with a header file, a .so file and I handle it. With the header file, the contract, we should be able to come up with something... So we managed to make our function call. But to be honest, I still strug...

PHP FFI: callbacks — part 3

The CallbackDuring the preparation of this article, I noticed that many resources on the internet directly use the libc for their examples. You can easily find fairly demonstrative and simple examples. But to do something cool and original, I thought to myself "let's find something to show with this libc too". After all… if it's just passing a structure as most examples do, it won't be useful. And then I came across a function in a forum where people were ...

PHP FFI: Passing Parameters — Part 2

Calling the PHP library directly?What if we had fun writing a piece of code that is useless? Come on!!! Come on!! Come on!!!Alright OK. I propose we do something useless by using PHP to call a C library that uses the Zend Engine.Actually, this paragraph is not as useless as it seems. Its purpose is to show you a particular behavior 😊PHP-FFI has a few limitations: you can't pass a PHP variable directly to retrieve its dynamic value from the external library.You only have access to passing C la...

PHP FFI: Introduction — Part 1

IntroductionSince version 7.4 of PHP, we finally have access to interoperability functions between different languages and PHP: the FFI or Foreign Function Interface.What is FFI? It is simply the ability to use an external library (.dll or .so) directly in PHP, without having to create a PHP extension. Yes, with just a PHP script! It is, among other things, what has made Python so famous and allowed it to have so many features.The great thing about FFI is that a PHP developer who is not an e...

Symfony 6 / Sonata 5: Installation of SonataClassification.

We have seen in previous articles how to initialize a Symfony 6 + Sonata 5 project with media and users in a secure admin. We then looked at how to manage user localizations.Now we will see how to install and manage classifications. We proceed with the installation of the latest version to date. php8.1 composer.phar require sonata-project/classification-bundle:5.x-dev Apparently, we have a configuration error. Unrecognized option "media" under "sonata_classification.class". Availabl...

Symfony 6 / Sonata 5: Link locales and the time zone to user preferences.

We saw in a previous article how to install Symfony 6 + Sonata Admin 5 with user and media management. We will continue this installation with the configuration of languages and time zones. We will install intlBundle which allows to manage localized display. php8.1 composer.phar require sonata-project/intl-bundle We take this opportunity to add a timezone and locale field to the user.To do this, we will extend userBundle and add a field in the admin...

Symfony 6 / Sonata 5: Initialize a Symfony 6 project + Sonata admin 5 + UserBundle + MediaBundle

Here are the commands to initialize a Symfony project with a secure admin. To run Symfony 6 we will need to install php8.0 or php8.1 For php8.0 sudo apt-get install php8.0-cli libapache2-mod-php8.0 php8.0-common php8.0-opcache php8.0-igbinary php8.0-imagick php8.0-msgpack php8.0-readline php8.0-memcached php8.0-xml php8.0-mbstring php8.0-gd php8.0-mysql php8.0-curl php8.0-intl php8.0-memcache php8.0-memcached memcached libapache2-mod-php8.0 php8.0-zip php8.0-mysql For...

Install Dropbox headless on a Linux server

Dropbox est un service de stockage et de partage de copies de fichiers locaux en ligne proposé par Dropbox Inc. Via un agent installé sur votre ordinateur ou mobile, il est capable de synchroniser une arborescence sur le cloud et permet ainsi une sauvegarde et un versionning de celui-ci.L’usage classique de Dropbox est d’utiliser un outil sur votre Desktop. Un usage moins évid...

Create a token on the Binance Smart Chain

We will see how to create a Token (Smart Contract) on é the Binance Smart Chain (BSC) and the déployer in order to allow à everyone to trade it.We are leaving from the principle that you know déjà the principles cryptocurrency, that you have some déjà buyé, and know how wallets work (wallets).Smart Contracts are programs that control édigital assets directly. These are these programs which, ...

Migration and upgrade of a GitLab CE server

Every 5 years, it's the same song and dance. The Debian LTS version is expiring, and it's time to update the server. It's also an opportune moment to upgrade to a newer machine to benefit from improved performance.If we have a SATA hard drive, it's better to start with new disks regardless, since their lifespan is limited. So we will proceed with a series of backups on the old server, transfer them to the new one, and reinstall everything as it was. In our case, we were on Debian 8, which sup...