@khakimjanovich you need to specify full namespace for AddFieldsToUsersTable class
if (!class_exists('\Namespace\AddFieldsToUsersTable')) {
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey there, i have a situation 😅. I created the package inside the package it has a migration file that adds rows to existing migration file. if I install the package it is now publishing that migration file even if the class exists. here is the code inside MyPackageProvider class
public function boot(): void
{
$this->publishes([ $this->configPath() => config_path('myconfig.php')], 'config');
if ($this->app->runningInConsole()) {
if (!class_exists('AddFieldsToUsersTable')) {
$this->publishes([
__DIR__ . '/../../database/migrations/add_fields_to_users_table.php.stub'
=> database_path('migrations/' . date('Y_m_d_His', time()) . '_add_fields_to_users_table.php'),
], 'migrations');
}
}
}
as you can see I checked before I publish the migration. But class_exists function is not working as it is intended to work
Please or to participate in this conversation.