Here's how PocketMine does it. I honestly don't know why you would want to handle NBT when there is already a function for it, but that example should get you started.
If a player sets custom name on an item by setcustomname() and puts in chest, it seems to be glitching like it disappears, could be due to lag.
I have seen your other thread and your server runs 11GB Memory/RAM... This cannot be a lag related issue. I will reproduce the issue myself. If it persists, feel free to open an issue on GitHub @ the PocketMine resporitory which you can find here; https://github.com/pmmp/PocketMine-MP
Honestly, why do you think would this solve "lag"? The only way to rename an item in Minecraft is by manipulation of nbt tags. Item::setCustomName() is just the better way. Don't reinvent the wheel.
Yes, however he isn't doing anything(that I know of) to make the wheel better. He is just doing what the setCustomName method already does. A better analogy would be driving a car with the convertible top down. It doesn't change the way the car functions, but it may cause you to have a bad time if it rains. If there are any NBT changes(Given what I've heard about the current NBT implementation, this is very possible), the setCustomName method in PMMP will most likely be updated to support those changes, possibly preventing you from having issues in your plugin.
but no one is stopping you, you may refer to how PMMP did it which may just result in the same lag issues
PHP: $item = Item::get(Item::BOW, 0, 1, NBT::parseJSON("{display:")); is this laggy or setCustomName();?
Honestly, no idea why you want to do this when there is already a function for that, but PHP: $nbt = new CompoundTag("", [ new CompoundTag("display", [ new StringTag("Name", $customName) ])]);$item->setCompoundTag($nbt);// orItem::get($itemId, $itemDamage, $itemCount, NBT::parseJson("{display:{Name:'$customName'}}");