Laravel-Source-Encrypter icon indicating copy to clipboard operation
Laravel-Source-Encrypter copied to clipboard

New migration syntax

Open Hoopex opened this issue 2 years ago • 10 comments

When, I try to encrypt a migration file

Old syntax

class CreateUserTableextends Migration {
}

Migration works without any issues


New syntax laravel >=8

return new class extends Migration {
};

Migration not working and returning that error Class "CreateUserTable" not found

Hoopex avatar Sep 29 '22 13:09 Hoopex

Which operating system are you using to develop? Which PHP version?

SiavashBamshadnia avatar Oct 07 '22 07:10 SiavashBamshadnia

Which operating system are you using to develop? Linux (Ubuntu)

Which PHP version? 8.1

You don't have that issue ?

Hoopex avatar Oct 07 '22 10:10 Hoopex

Actually I don't use Ubuntu. But I think this error is not related to this package. Try running the original code (without encryption) and see if the error still exists.

SiavashBamshadnia avatar Oct 07 '22 13:10 SiavashBamshadnia

I think it related to this package because the original source (without encryption) works, but encrypted source I got that error. and to make it work, I have to give manual class name to all migrations

From return new class extends Migration {};

To class CreateUserTable extends Migration {}

Hoopex avatar Oct 07 '22 21:10 Hoopex

Okay, @Hoopex. Thanks for reporting this problem. I will check it.

SiavashBamshadnia avatar Oct 08 '22 07:10 SiavashBamshadnia

Hello, @Hoopex. Sorry for the late response... I got to install Ubuntu and check the scenario. I installed PHP 8.1 and created a Laravel project with the composer. Then, I installed the sbamtr/laravel-source-encrypter and tried to encrypt the project. Finally, migrations were encrypted without any problem. The migrations were the default ones that those are: https://github.com/laravel/laravel/tree/586b9e7bf5efef4d205552cc285a3f8498767578/database/migrations I think you are using the wrong version of phpbolt.

SiavashBamshadnia avatar Oct 18 '22 08:10 SiavashBamshadnia

Hi Mr @SiavashBamshadnia

  • Finally, migrations were encrypted without any problem. It's not about encryption, the issues about migrations when you try to run php artisan migration command.

I test that again with fresh laravel project and the I got the same result, and I can confirm that I', using the right phpbolt version.

Hoopex avatar Oct 22 '22 18:10 Hoopex

Any updates by any chance ?

Hoopex avatar Oct 27 '22 20:10 Hoopex

Hello. I think phpbolt does not support anonymous classes. As a result, I created an issue in phpbolt's repository.

SiavashBamshadnia avatar Oct 29 '22 17:10 SiavashBamshadnia

+1

jamesRUS52 avatar Jan 09 '23 14:01 jamesRUS52