The trick to “cancel” your pending transaction is by replacing the transaction with BTC amount send back to yourself but with higher transaction fees.
This is useful also when your transaction stuck in mempool. Replace it with new transaction with higher transaction fees.
Theorically you just have around 10 minutes interval to carry out this action before transaction comfirmation turn to 1.
nSequence in any input with value of <= 0xfffffffd will enable RBF.
$tx = $tx->input($utxo_hash, $utxo_n_output, null, 4294967293);
$tx = $tx->spendOutputFrom($utxo_hash, $utxo_n_output, null, 4294967293);
Above codings nSequence 4294967293 equal to 0xfffffffd.