Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL json >= 1.2.0
Returns the JSON representation of a value
<?php json_encode(mixed $value, int $flags = 0, int $depth = 512): string|false
<?php $this->browse(function ($browser) {
$this->visitLivewireComponent($browser, Component::class)
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts',
]))
->waitForLivewire()->click('@toggle-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts',
<?php 'parent-scripts',
]))
->waitForLivewire()->click('@toggle-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts',
]))
->waitForLivewire()->click('@toggle-child')
->waitForLivewire()->click('@toggle-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
<?php ]))
->waitForLivewire()->click('@toggle-child')
->waitForLivewire()->click('@toggle-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts',
]))
->waitForLivewire()->click('@refresh-parent')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts',
<?php 'parent-scripts', 'child-scripts',
]))
->waitForLivewire()->click('@refresh-parent')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts',
]))
->waitForLivewire()->click('@toggle-blade-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts', 'child-blade-scripts', 'child-blade-scripts-no-once', 'child-blade-scripts-no-once',
<?php 'parent-scripts', 'child-scripts',
]))
->waitForLivewire()->click('@toggle-blade-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts', 'child-blade-scripts', 'child-blade-scripts-no-once', 'child-blade-scripts-no-once',
]))
->waitForLivewire()->click('@toggle-blade-child')
->waitForLivewire()->click('@toggle-blade-child')
->waitForLivewire()->click('@refresh-child')
<?php ->waitForLivewire()->click('@toggle-blade-child')
->waitForLivewire()->click('@toggle-blade-child')
->waitForLivewire()->click('@refresh-child')
->assertScript('JSON.stringify(window.stack_output)', json_encode([
'parent-scripts', 'child-scripts', 'child-blade-scripts', 'child-blade-scripts-no-once', 'child-blade-scripts-no-once',
]))
;
});
}
<?php {
$tmp = __DIR__ . '/_runtime_components.json';
file_put_contents($tmp, json_encode($components, JSON_PRETTY_PRINT));
}
function wipeRuntimeComponentRegistration()
<?php return htmlspecialchars($subject, ENT_QUOTES|ENT_SUBSTITUTE);
}
return htmlspecialchars(json_encode($subject), ENT_QUOTES|ENT_SUBSTITUTE);
}
static function pretendResponseIsFile($file, $contentType = 'application/javascript; charset=utf-8')
<?php $file = storage_path('framework/cache/lw-checksum-log.json');
Artisan::command('livewire:monitor-checksum', function () use ($file) {
File::put($file, json_encode(['checksums' => [], 'failure' => null]));
$this->info('Monitoring for checksum errors...');
<?php $cache['failure'] = null;
}
File::put($file, json_encode($cache));
sleep(1);
}
<?php $good = $this->array_diff_assoc_recursive($canonicalSnapshot, $tamperedSnapshot);
$bad = $this->array_diff_assoc_recursive($tamperedSnapshot, $canonicalSnapshot);
$cache['failure'] = "\nBefore: ".json_encode($good)."\nAfter: ".json_encode($bad);
File::put($file, json_encode($cache));
});
<?php $cache['failure'] = "\nBefore: ".json_encode($good)."\nAfter: ".json_encode($bad);
File::put($file, json_encode($cache));
});
on('checksum.generate', function ($checksum, $snapshot) use ($file) {
<?php $cache['checksums'][$checksum] = $snapshot;
File::put($file, json_encode($cache));
});
}
<?php HTML;
}
})
->assertSeeIn('@output', json_encode(['one' => 'One', 'two' => 'Two', 'three' => 'Three']))
->waitForLivewire()->click('@set')
->assertSeeIn('@output', json_encode(['one' => 'One', 'three' => 'Three', 'two' => 'Two']))
->waitForLivewire()->click('@set-add')
<?php })
->assertSeeIn('@output', json_encode(['one' => 'One', 'two' => 'Two', 'three' => 'Three']))
->waitForLivewire()->click('@set')
->assertSeeIn('@output', json_encode(['one' => 'One', 'three' => 'Three', 'two' => 'Two']))
->waitForLivewire()->click('@set-add')
->assertSeeIn('@output', json_encode(['one' => 'One', 'three' => 'Three', 'two' => 'Two', 'four' => 'Four']))