When Doctrine Generate doctrine/base/*.class.php - doctrine

I am having a web site live built with symfony 1 and Doctrine.
sometimes i get error like:
Doctrine don't have the permission to write on
../../../model/doctrine/base/BaseClassName.class.php
But i didn't change any permission. So why and when Doctrine regenerate those files?

Base classes are generated when invoking
./symfony doctrine:build-model
or
./symfony doctrine:build
from command line. There's no code to generate these classes for you when it's not generated yet. You will get fatal error in that case.

Related

How in custom package data checking with making plugin unavailable in case of error?

Making custom package with custom data kept in migration/seeder files on laravel 9 site and reading docs https://laravel.com/docs/9.x/packages
I did not find in which way I can run some data checking on plugin installation ?
In file packages/companyname/Mypackage/src/Providers/MypackageProvider.php
I have loaded migration files :
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
I have a custom class, running which I got list of errors in case of data in related tables have logical errors.
I think to make functionality to run this checking process from dashboard of my site
Also I would like in case of such errors to show some errors when I run this checking process manually and maybe (if that is possible)
when I run commands in console of the site :
composer install mypackage
composer dump-autoload
and migrating migration/seeder files of this plugin...
Also is cases of logical errors I would like in the app make a condition like :
if(class_exists(mypackage::class)) {
and make functionality of this plugin unavailable...
How that can be implemented ?
"laravel/framework": "^9.41"
Thanks in advance!
If I understand what you want to do is check some conditions on the user app before your package may be used, but I think you can check these conditions before the user install the package, executing an script before installing the package using a composer script pre-install-cmd. After installing your package you can use the boot method of your service provider and execute all those conditions that have to be meet before using the functionality and abort if they are not presents.
Hope this help.

Storage not building the right file url in test?

I'm writing tests for my application and struggling to understand whi Storage class is not building the expected file url.
I'm having thist test that fails on asserting that expected url equals the builded one, so i put an if in my code and dd() stuff out to understand, and that's the result:
IF in my test
if('http://testurl/storage/path/to/file.test' !=
Storage::disk('default_disk')->url('path/to/file.test')){
dd(
config('filesystems.disks.default_disk'),
Storage::disk('default_disk')->url('path/to/file.test'),
);
}
Output
> php vendor/phpunit/phpunit/phpunit
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.3
Configuration: C:\Users\silvi\Desktop\RawFile\phpunit.xml
array:3 [
"driver" => "local"
"root" => "root/"
"url" => "http://testurl/storage"
]
"/storage/path/to/file.test"
Script php vendor/phpunit/phpunit/phpunit handling the test event returned with error code 1
Considerations
So in my test the disk configuration is OK, but the Storage class build the wrong url like it is ignoring the url config section.
Don't think this matters, but (obviously) the storage is fake, made with Storage::fake('default_disk'); in the setUp() method.
Laravel
I'm writing tests for a Laravel package, and used "orchestra/testbench": "^6.2" as dev dependancy, so according to their docs it brings up a Laravel 6 application skeleton.
Update
I tried removing the Storage::fake('default_disk'); and the test passed, having the Storage correctly using my configs.
As gbalduzzi said, if the storage is fake it ignores whatever is in my configs.
When you use fake() to create a disk, Laravel will not consider anymore your configuration from the usual file config/filesystems.php.
It will create a custom, fake, disk.
To solve your problem, you should use the actual disk without creating it using fake(). This is not ideal though, because running your tests will actually add files into the selected storage.
The fact is, you should not be testing that the Storage facades builds the proper url. Your tests should focus on the code written by YOU. It is laravel job to properly test their interfaces/methods/facades.

Including a php file from another server in Laravel controller

Hello i am try to include a PHP class (Payroll.php) found on another server since it requires the main module that has been written in pure PHP in my Laravel sub-module. I was given the url to the php file on the other server and have been tasked with using it to fetch the employees from the main module to be used in my module. Almost all the solutions i found on the internet where for cases where the laravel code and the php code exist on the same server. I tried several approaches such as including the file directly (which is giving me class not found) and using things like guzzle and so on (which failed since it is not an API). Any help would be appreciated.

Scaffolding error with CodeIgniter_2.1.2

I am using codeigniter 2.1.2 and I want to use scaffolding feature to add information to table. When I set this $route['scaffolding_trigger'] = 'scaffolding'; in routes.php and call it in controller $this->load->scaffolding('applicants'); I get the following Error:
Fatal error: Call to undefined method CI_Loader::scaffolding() in C:\xampp\htdocs\hmplatform\application\controllers\Applicant.php on line 6 So I am asking if I can find a library that contains scaffolding features because in this version I downloaded from GIT there is no scaffolding folder.
Scaffolding was depreciated in codeigniter. It isn't longer offered. The tutorials are outdated, so I'm guessing this is where you saw it?

Doctrine 2.2 Bisna CLI

I can't get the Bisna doctrine cli to work. It complains about not being able to find the Symfony Console application. Notice it's trying to look for it in a nested directory of Doctrine/Symfony/Console/Symfony/Component/Console. Anybody ever seen this?
PHP Warning: require(/Users/jhicks/workspace/production/application/../library/Doctrine/Symfony/Console/Symfony/Component/Console/Application.php): failed to open stream: No such file or directory in /Users/jhicks/workspace/production/library/Doctrine/Common/ClassLoader.php on line 163
PHP Fatal error: require(): Failed opening required '/Users/jhicks/workspace/production/application/../library/Doctrine/Symfony/Console/Symfony/Component/Console/Application.php' (include_path='/Users/jhicks/workspace/production/library:.:/opt/local/lib/php') in /Users/jhicks/workspace/production/library/Doctrine/Common/ClassLoader.php on line 163
Here's the Github page for the doctrine cli from Bisna: https://github.com/guilhermeblanco/ZendFramework1-Doctrine2/blob/master/bin/doctrine.php
There are many repositories that call themsemves Bisna in Github, it is difficult to find what of them you are using without further information.
The original one is the one created by Guilherme Blanco (Bisna used to be his nickname) called Zend Framework 1 + Doctrine 2 and works like a charm, but it does not bundle the Symfony components necessary to run the CLI tool.
What you have to do is download them from GitHub (search for "Symfony" and you will find the components inside the Organization repository) and put them inside your project's library folder paying attention to the PSR #0 naming conventions.
If you provide the piece of code that generates this error and the repository and version you are using, it will be easier to detect the error and give a better answer. It is naive to try and guess the type of error, but probably you have problems with namespaces and/or how you are calling Symfony's Console component.
If you need some guidance on how this integration can be achieved, you can look at doctrine.php inside Blanco's repository.
Looks like I needed to add these two lines to my existing autoloader bootstrap method:
$symfonyAutoloader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
$autoloader->pushAutoloader(array($symfonyAutoloader, 'loadClass'), 'Symfony');
I didn't think this would be necessary since I included Symfony in the autoloaderNamespaces array in my application.ini file.
autoloaderNamespaces[] = "Symfony"

Resources