Closed iamraffe closed 9 years ago
The issue seems to be in Console\RepositoryMakeCommand.php
protected function getPath($name)
{
-> $name = str_replace($this->getAppNamespace(), '', $name);
$path = $this->laravel['path'].'/'.str_replace('\\', '/', $name).'Repository.php';
if ($this->option('which') == 'implementation') {
$filename = $this->argument('name') . 'Repository.php';
$path = str_replace($filename, 'Parse'.$filename, $path);
}
return $path;
}
Changing for:
$name = str_replace($this->getNamespace($name), '', $name);
allows to run the command but then we get stub errors:
<?php
namespace {{namespace}};
use LaraParse\Repositories\Contracts\ParseRepository;
/**
<?php
namespace {{namespace}};
use LaraParse\Repositories\AbstractParseRepository; use {{namespace}}\Contracts{{class}}Repository;
class Parse{{class}}Repository extends AbstractParseRepository implements {{class}}Repository {
/**
* Specify Parse Class name
*
* @return string
*/
public function getParseClass()
{
return 'ClassName';
}
}
So lastly, RepositoryMakeCommand.php is extending Illuminate\Console\GeneratorCommand.
Now the issue here is they have DummyClass instead of {{class}}, DummyNamespace {{namespace}} and DummyRootNamespace instead of {{rootNamespace}}.. So no wonder it wasn't working.
Once I replaced those in the replaceNamespace and replaceClass methods it seems to be working properly again.
Dunno if I'm the only one seeing this issues but I am working with a fresh install of laravel and then running the composer require command to install laraparse so.. Maybe this helps someone.
i'm seeing it too. overlooked when i tested it with 5.1 (hence the issue i raised for getting some tests wrote for this stuff).
Rather than changing the $name = str_replace($this->getNamespace($name), '', $name); line i think use $this->laravel->getNamespace() OR implementing the \Illuminate\Console\AppNamespaceDetectorTrait trait
If you use only: $this->laravel->getNamespace()
Then you get asked for a parameter, that's why I added the $name just to see if that worked.
$name = str_replace($this->laravel->getNamespace(), '', $name);
In the GeneratorCommand it uses this in the getPath() method.
Also, I think you should be updating the stub rather than the GeneratorCommand because then your changes will get overwritten if that package gets updated. Will commit the fix for this tonight. Thanks for spotting that!
<?php
namespace DummyNamespace;
use LaraParse\Repositories\AbstractParseRepository;
use DummyNamespace\Contracts\DummyClassRepository;
class ParseDummyClassRepository extends AbstractParseRepository implements DummyClassRepository
{
/**
* Specify Parse Class name
*
* @return string
*/
public function getParseClass()
{
return '{{parseClass}}';
}
}
that;s what the stub should look like. Just a case of going through and replacing {{class}} with DummyClass, and {{namespace}} with DummyNamespace
Ok, will do.
All my recent projects seem to be Parse based, so I will help in all I can haha
yeah Parse is pretty awesome. Especially when it comes to mobile apps!
There still seems to be some stuff to work out with 5.1
When using php artisan parse:subclass ClassName
I get error "[RuntimeException]
Unable to detect application namespace. "
or if it does run I get stuff like:
<?php
namespace {{namespace}};
use Parse\ParseObject; use LaraParse\Traits\CastsParseProperties;
/**
@package LaraParse */ class {{class}} extends ParseObject { use CastsParseProperties;
public static $parseClassName = 'ClassName'; }
which didn't happen previously.
Same thing with repositories with the artisan command
php artisan parse:repository User [Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method LaraParse\Console\RepositoryMakeCommand::getAppNamespace()
Am I the only one getting this?