New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom source not found (in version 5.0.9) #136

Closed
tonirenner opened this Issue Apr 23, 2018 · 7 comments

Comments

Projects
None yet
2 participants
@tonirenner

tonirenner commented Apr 23, 2018

Hi,

i added a custom source in my bootstrap file like this

<?php
require_once __DIR__ . '/../../vendor/autoload.php';

phpbu\App\Factory::register(
	'source',
	'<alias>',
	'<classname>'
);

and run phpbu with --bootstrap=bootstrap.php.

Works with phpbu 5.0.8, but in version 5.0.9 i got an error "unknown source".

Looks like issue #124.

Can you verify, please?

Thanks,
Toni

@sebastianfeldmann sebastianfeldmann self-assigned this Apr 24, 2018

@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 24, 2018

I'll check

@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 24, 2018

So, this is working for me :)

backup/bootstrap.php

<?php
use phpbu\App;
class MySource implements App\Backup\Source
{
    public function setup(array $conf = [])
    {
        // foo
    }

    public function backup(App\Backup\Target $target, App\Result $result): App\Backup\Source\Status
    {
        $status = new App\Backup\Source\Status();
        $status->uncompressedFile('foo');

        return $status;
    }
}
App\Factory::register('source', 'dummy', MySource::class);

phpbu.xml

<phpbu  bootstrap="backup/bootstrap.php">
  <backups>
    <backup name="custom">
      <source type="dummy">
        <option name="dummy" value="dummy"/>
      </source>
      <target dirname="backup/dummy" filename="dummy-%Y%m%d-%H%i.txt"/>
    </backup>
  </backup>
</phpbu>

Resulting output

phpbu 5.0.9 by Sebastian Feldmann and contributors.

Time: 120 ms, Memory: 4.00MB

OK (1 backup, 0 checks, 0 crypts, 0 syncs, 0 cleanups)
@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 25, 2018

Can you reproduce this?

What kind of installation are you using?
Composer or PHAR?

Which php version are you using?

Windows Linux MacOS?

@tonirenner

This comment has been minimized.

tonirenner commented Apr 26, 2018

Hi,
i use the PHAR on a linux (ubuntu/centos). I figured out that when i do somthing like this

<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/5.0/phpbu.xsd"
       bootstrap="bootstrap.php">
	<backups>
		<backup name="custom">
			<source type="dummy">
				<option name="dummy" value="dummy"/>
			</source>
			<target dirname="backup/dummy" filename="dummy-%Y%m%d-%H%i.txt"/>
		</backup>
	</backups>
</phpbu>

it works.

vagrant@www:/vagrant$ php vendor/tm/tooly-composer-script/bin/phpbu.phar --configuration=/vagrant/config/backup/phpbu.xml --bootstrap=/vagrant/config/backup/bootstrap.php
phpbu 5.0.9 by Sebastian Feldmann and contributors.

Time: 444 ms, Memory: 6.00MB

OK (1 backup, 0 checks, 0 crypts, 0 syncs, 0 cleanups)

If i dont specify the bootstrap file (bootstrap="bootstrap.php") like this

<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/5.0/phpbu.xsd">
	<backups>
		<backup name="custom">
			<source type="dummy">
				<option name="dummy" value="dummy"/>
			</source>
			<target dirname="backup/dummy" filename="dummy-%Y%m%d-%H%i.txt"/>
		</backup>
	</backups>
</phpbu>

it doesn't work.

vagrant@www:/vagrant$ php vendor/tm/tooly-composer-script/bin/phpbu.phar --configuration=/vagrant/config/backup/phpbu.xml --bootstrap=/vagrant/config/backup/bootstrap.php
phpbu 5.0.9 by Sebastian Feldmann and contributors.

Time: 581 ms, Memory: 4.00MB

Exception 'phpbu\App\Exception' with message 'unknown source: dummy'
in phar:///vagrant/vendor/tm/tooly-composer-script/bin/phpbu.phar/Factory.php:104

FAILURE!
Backups: 1, failed Checks: 0, failed Crypts: 0, failed Syncs: 0, failed Cleanups: 0.

But correct me if i'm wrong, but in version 5.0.8 (and before) i dont had to specifiy the bootstrap file in the configuration (https://phpbu.de/manual/current/en/extending-phpbu.html "Example 11.13: Example phpbu.xml.dist")?

Thanks
Toni

@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 26, 2018

oO I'll check if i crashed the bootstrap option in 5.0.9

@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 27, 2018

Indeed I did... fix is coming

sebastianfeldmann added a commit that referenced this issue Apr 27, 2018

Fix bootstrap cli option handling - issue #136
After fixing the adapter chicken and egg problem the
bootstrap handling was moved up. That resulted in handling
the bootstrap file before handling the cli bootstrap option.

The bootstrap option is now handled at the right time and
its value is passed to the Bootstrapper constructor.
@sebastianfeldmann

This comment has been minimized.

Owner

sebastianfeldmann commented Apr 27, 2018

I've just released version 5.0.10 that fixes the bootstrap cli option issue.

Your hunch was absolutely right by fixing the adapter chicken and egg problem I introduced
another one with the bootstrap handling.

Thank you for reporting and helping to get to the bottom of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment