Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Still problem with file system. #6

Closed
alextech opened this issue Apr 24, 2018 · 9 comments
Closed

Still problem with file system. #6

alextech opened this issue Apr 24, 2018 · 9 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@alextech
Copy link
Contributor

alextech commented Apr 24, 2018

  1. Getting same error with latest flysystem in actual project

default

Attempted usage:

throw Fault::exception(\Importer\ImporterException::class, 'Problem selecting sheet', 1002, $e);
  1. It is writing to _compiled under omegad-biz. That is a problem, because hosts will not have write permissions there. Write permissions will be often given manually to designated directory, such as data at top level.
@panosru panosru reopened this Apr 25, 2018
@panosru
Copy link
Owner

panosru commented Apr 25, 2018

I messed up the commit issue reference, the above commit is referring to issue #7, so we continue there.

@panosru
Copy link
Owner

panosru commented Apr 25, 2018

@alextech the package by default uses the _compiled directory which is inside the package.

In the case that write permissions are not enabled then you can use Fault::setCompilePath('/my/path'); before executing any other Fault::* methods.

let me know if that solves your issue

Description


public void \Omega\FaultManager\Fault::setCompilePath ( string $path )

@panosru
Copy link
Owner

panosru commented Apr 25, 2018

also please note that throw Fault::exception(\Importer\ImporterException::class) won't work as namespaces are not yet supported.

Actually now that I tested it, it will break your application if you use namespaces because it will create a path _compiled/Importer/ImporterException.php and next time you will run your app you will receive errors like

Notice: Undefined index: extension in ...

Fatal error: Uncaught TypeError: strcmp() expects parameter 2 to be string, null given in ...

I probably have to add a check for that or implement namespaces.

@panosru
Copy link
Owner

panosru commented Apr 25, 2018

@alextech please run composer update omegad-biz/fault-manager for now. This concept is something discussed in #4 but not yet implemented.

@alextech
Copy link
Contributor Author

\Omega\FaultManager\Fault::setCompilePath(__DIR__.'/../data/exceptions');

has no effect. New classes are still created in vendor.

@panosru panosru self-assigned this Apr 25, 2018
@panosru panosru added the bug Something isn't working label Apr 25, 2018
@panosru
Copy link
Owner

panosru commented Apr 25, 2018

Let me know where you place the above code as I just checked and it works on my side.

Remember, Fault is a static class so setCompilePath needs to be called before Fault::exception or Fault::throw in order to be taken into account.

@alextech
Copy link
Contributor Author

Sorry, I forgot my unit tests, do not go through entire pipeline initialization code, where I put that function. I will have to add this to application configuration service in a way that it is applied in all places on my end.

@panosru
Copy link
Owner

panosru commented Apr 25, 2018

You can change your path everywhere and anytime you need.

For instance:

Fault::setCompilePath('/my/path');
Fault::exception('MyCustomException'); // compiled file will be under /my/path
Fault::setCompilePath('/my/other/path');
Fault::exception('MyOtherCustomException'); // compiled file will be under /my/other/path
// etc...

For unit testing you can have something like that:

/**
 * @before
 */
protected function setTestPath(): void
{
    Fault::setCompilePath('/my/testing/path');
}

Code example

@panosru
Copy link
Owner

panosru commented Apr 25, 2018

In addition to the above example, my mistake is that I forgot to append front-slash at the end of the path so /my/path should be /my/path/.

I probably need to have a check for that and in a case is missing to append a trailing front-slash to the path.

@panosru panosru reopened this Apr 25, 2018
panosru added a commit that referenced this issue Apr 26, 2018
@panosru panosru closed this as completed Apr 26, 2018
@panosru panosru added this to To do in Library via automation Apr 26, 2018
@panosru panosru moved this from To do to Done in Library Apr 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Library
  
Done
Development

No branches or pull requests

2 participants