Git Product home page Git Product logo

laravel-doctrine's People

Contributors

baileylo avatar bangipul avatar cosmicist avatar foxxmd avatar glennjacobs avatar jeremyworboys avatar kirkbushell avatar leonardoalifraco avatar mitchellvanw avatar psampaz avatar sephvelut avatar soyuka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-doctrine's Issues

YAML Metadata

Would adding YAML support just be a case of modifying the service provider line 83 to get a value from the config file and either call

$metadata = Setup::createAnnotationMetadataConfiguration(...);

or

$metadata = Setup::createYAMLMetadataConfiguration(...);

Based on the value, or is would there be more involved?

Add connection config option

Can we add a config option to set which DB connection to use? The only real change is to line 149 of the service provider to use $config['doctrine::doctrine.connection'] ?: $config['database.default'] and, of course, the line in the config file.

Rationale: I'm using the database for things other than doctrine's entities, so I'd like doctrine to use its own database connection. Also just generally a good config option to have.

I can submit a PR for this if approved.

IDEA: Can we defer laravel-doctrine booting until needed?

I'm finding that with artisan commands, I generally don't need a database connection until I run a query or anything else of that nature. Is it possible we can somehow lazy-load the database connection and configuration until it's actually required?

Config does not override default

The published config file does not overwrite the default settings. I imagine it's something to do with the namespace change from a month or two ago.

If I get a change tomorrow I'll have a look and submit a PR.

DBAL tries to connect even when it's not used

Is there a way to implement connecting to the database lazily?
It even breaks when using artisan dump-autoload if mysqld is down while it shouldn't even bother connecting with DBAL.

Keep up the good work.

Table Prefixing

Hi guys,

Does this package follows the database configuration in laravel ? I've tried adding a prefix but after I generate the schema from the annotations it doesn't show up ?

Published config file changes are disregarded

I installed the package on a fresh laravel project (no other packages installed) and published the config file as described in the readme. I changed metadata path in the published config file but when I use schema commands (e.g. doctrine:schema:create), the default value from vendor folder is read by laravel instead of the published config file's. Composer autoload dump does not have any effect.

Timestamp TrashedFilter issue

Been using the Timestamps trait and I get an error when running a query.

The following line appears to be the problem

return "{$table}.deleted_at IS NULL || NOW() < {$table}.deleted_at";

When I change it to this, all seems fine (changed || to OR)

return "{$table}.deleted_at IS NULL OR NOW() < {$table}.deleted_at";

Class auth does not exist

I'm using:

    "laravel/framework": "4.2.*",
    "codesleeve/asset-pipeline": "dev-master",
    "rhumsaa/uuid": "*",
    "doctrine/orm": "2.5.*",
    "symfony/yaml": "3.*",
    "mitchellvanw/laravel-doctrine": "0.5.*"

When I run php artisan, I got this error.

{"error":{"type":"ReflectionException","message":"Class auth does not exist","file":"\/bootstrap\/compiled.php","line":235}}

If I remove this line ( https://github.com/mitchellvanw/laravel-doctrine/blob/master/src/LaravelDoctrineServiceProvider.php#L30 ) it works fine.

Doctrine Commandline Tools

Hi,
I tried to use Commandline Tools. According to official guide, I can use this command to generate getters and setters:

php/vendor/doctrine orm:generate-entities

but I get this error:

You are missing a "cli-config.php" or "config/cli-config.php" file in your
project, which is required to get the Doctrine Console working. You can use the
following sample as a template:

ReflectionException Class auth does not exist

When using a namespaced app and injecting the entityManager into an abstract base controller. I have a route pointed to a Crunch\Controller\PageController@homePage that does nothing but echo "homepage" in it's action.

http://laravel.io/bin/1bGkv for all of the relevant code. Can you point out what is going wrong with this for me? The doctrine commands work on a user model using the Authentication trait.

From the whoops error stack it appears it's happening here:

/mitch/laravel-doctrine/src/LaravelDoctrineServiceProvider.php on line 94

Doctrine 2.4

Is there a reason that this package depend on a beta version of doctrine? Why not to stick with the stable one (2.4)?
I think changing minimum-stability to dev should be avoided if possible.

Suggestion about annotation.

Hi,

We maintain a large app using doctrine. We have used silex for creating the ORM/composer lib , using the annotation style that you have used in your example.

We wanted to use that ORM lib with Symfony to quickly create an API. But we failed because symfony needs full namespace to annotation classes.

So, we ditched the symfony api creation. (maybe there was work around)

So, I am tryin to say is use full paths to annotation, rather relying on autoload magic.

//Best

Charset encoding issues

I'm having an issue with the response from tables containing UTF-8 encoded data misinterpreting the charset. After debugging I found the issue to be related to the way the connection to the database is established.

The solution I found is to return a charset key from LaravelDoctrineServiceProvider::getDatabaseConfig() (preferably read from the Laravel db config).

Alternatively, instead of building your own connection config, you can pass the result of $app['db']->getDoctrineConnection() into EntityManager::create() and remove LaravelDoctrineServiceProvider::getDatabaseConfig() altogether.

I am happy to put make a pull request for this if you let me know your preferred approach.

Authentication problem

Gentlemen:

I'm getting de following error when I'm trying to authenticate a user (when calling Auth::attempt() in Controller):

Doctrine\Common\Persistence\Mapping\MappingException
Class 'User' does not exist

I did everything you explain in the documentation, but I'm stuck with this error.

Can you help me, please?

Thanks in advance,

Ernesto
ctrllogin
user

Add In Support For Doctrine Extensions

Hello,

Thanks for developing this package. It would be nice to add in support for Doctrine Extension into this package. I was thinking the main composer file would add in the Doctrine Extensions. But the configuration and inclusion would be set via this package's config file.

Example, in the file app/config/packages/mitchellvanw/laravel-doctrine/doctrine.php have a config array

['extension' => ['\Gedmo\Tree\TreeListener', 'Gedmo\Loggable\LoggableListener' ]]

Help with Error creating schemas

I think a User entity as in the example of the package and when I run the 'php artisan doctrine: schema: create' command gives me an error and that's not what happens. The error:

C:\xampp\htdocs\laravel>php artisan doctrine:schema:create
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","me
ssage":"syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRI
NG) or variable (T_VARIABLE) or '{' or '$'","file":"C:\xampp\htdocs\laravel
vendor\mitchellvanw\laravel-doctrine\src\LaravelDoctrineServiceProvider.php"
,"line":58}}

Laravel 5

Laravel 5 has broken compatibility for the UserProvider.

I've fixed it locally, but it will not work with Laravel 4 - how do you want to handle this? Make a branch specifically for Laravel 5?

YAML,PHP mappings

Hi guys, how do you generate the fields created in the YAML or PHP ?

Creation/Update of schema does not work

I ran the following:

$ php artisan doctrine:schema:create --env=local
Creating database schema...
Schema has been created!

$ php artisan doctrine:schema:update --env=local
Checking if database needs updating....
Updating database schema....
Schema has been updated!

Everything seems to be fine, but nothing happens. I got a annotated Model in my models directory and dumped the autoloader.

The following command works

$ php artisan migrate --env=local

SQLite driver not supported

The pdo_sqlite driver doesn't work because the service provider is trying to grab values from nonexistent array keys (which are irrelevant for sqlite). Trying to use an sqlite driver raises Undefined index: host from LaravelDoctrineServiceProvider.php:143.

Maybe a simple if/else for now, as sqlite seems to be the odd one out?

Paginator::make

Has anyone done anything nice with this package and Paginator::make?

Just coming to paginate results now and wondered if there was a nice way of doing it.

support for multiple namespace for proxies

does this package have a support for multiple namespace for proxies just like in the metadata in config.php

'metadata' => [
   base_path('app/models')
 ],

'proxy' => [
  'auto_generate' => false,
  'directory'     => [
     base_path('app/<vendor_name>/modules/<module_name_1>/proxy'),
     base_path('app/<vendor_name>/modules/<module_name_2>/proxy')
   ],
   'namespace'     => null
 ],

Configuring metadata within a package.

Hello, I'm trying to use Laravel Doctrine within a package, and I'm struggling to find a good way of adding paths to the metadata configuration array without changing the config file itself.

Is there a recommended way to do this?

I realise one way might be:

Config::set(
    'mitchellvanw/laravel-doctrine::doctrine.metadata',
    array_merge(
        Config::get('mitchellvanw/laravel-doctrine::doctrine.metadata'),
        [
            'foo/bar',
            'baz/qux'
        ]
));

However surely there is a cleaner way to do it.

Sqlite memory database vs migrations

Hi,

I tried to switch to an sqlite in memory database for my tests, but after running my migrations, laravel-doctrine does not found any of the tables created by the migrations.
I suppose that is because the migrations were made with the Laravel Schema::create Facade, which uses another sqlite connection, and in memory databases are per connection.

I was wondering then how should i architect my migrations and seeds in order to be made with the same connection that laravel-doctrine will use.

Validation - uniqueness

Currently if you try and run the uniqueness validation that L4 provides, it will go via Eloquent, setting up a new database connection and do all that double-edged lovely goodness. The problem is, that's not what we want - we need to setup a new DatabasePresenceVerifier that can handle this for us.

This isn't as straight-forward as we'd like. Any ideas as to how this could be handled nicely? Open question/brainstorm session to see what we can come up with.

Version 0.5.0

Hello everybody,

Many people have had requests for this package. Of course I want to built every single one of them. Now, I don't want to keep you out of the loop and that's why I made this update. I'm working on the next version, which is 0.5.0. This version will contain the following updates:

  • Supporting MySQL, PostgreSQL and SQLite.
  • Supporting Read / Write Connections.
  • Ability to add Extensions
  • Supporting table prefix setting

These are the main things I'm adding in the upcoming release. I'm also looking into #15 and what the possibilities are here.

I'll most likely have this released in 2 weeks, before October 1st.

I already thinking about version 0.6.0 and would like your help with what this will contain. I've created a label named Version 0.6.0, so if you have an idea for this version then add this label to your issue.

Thanks

Undefined method getKeyName()

When using the doctrine authentication driver, I am recieving the error call to undefined method getKeyName().

I traced it down to an issue within the DoctrineUserProvider class. It assumes that all entities will have the getKeyName() method. All eloquent models will, as they must extend the base Eloquent class, however Doctrine entities won't.

My suggestion is to use getKeyName() if it exists, or else just default to id.

Issue with installation through composer

I did a fresh install of laravel, then I added the following to the composer.json file:

"require": {
    "laravel/framework": "4.1.*",
    "doctrine/orm": "*",
    "mitch/laravel-doctrine": "0.*"
},

I added doctrine based on the message I received, but I still received errors without the doctrine in the require.

Here is the error that I get when I run a composer install.

Problem 1
- mitch/laravel-doctrine 0.3.3 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.3.2 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.3.1 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.3.0 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.2.4 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.2.3 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.2.2 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.2.1 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.2 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.1.2 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.1.1 requires doctrine/orm 2.5.* -> no matching package found.
- mitch/laravel-doctrine 0.1 requires doctrine/orm 2.5.* -> no matching package found.
- Installation request for mitch/laravel-doctrine 0.* -> satisfiable by mitch/laravel-doctrine[0.1, 0.1.1, 0.1.2, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3].

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Double class definitions when generating schema with files already autoloaded

So doctrine's schema tool is meant to scan certain folders for files to parse as entities, and generate schemas thereof. A problem occurs when using commands such as php artisan doctrine:schema:create in an environment where the classes it scans are already loaded, in my case by service provider setups.

For instance, in doctrine.php:

    'metadata' => [
        base_path('NS/Users')
    ],

If there exists a class NS\Users\UserServiceProvider, and it's included in the config service provider listing, this class is initiated by laravel as soon as the app is booted up. When doctrine goes through the files to parse for entities, the service provider is already loaded into PHP and PHP refuses the double declaration:

$ php artisan doctrine:schema:update
Checking if database needs updating....
PHP Fatal error:  Cannot redeclare class NS\Users\UserServiceProvider in /NS/Users/UserServiceProvider.php

One cheap way to fix this is by moving entities into their own namespace, but this isn't very ideal (I would prefer to just use my namespace root instead of having to specify each subfolder) and isn't foolproof either; sometimes a service provider would autoload an entity as well, e.g. to provide an IoC binding. This would throw the error in any situation as long as the service provider was invoked.

The only real solution would be to execute the schema generation in some way such that other service providers aren't loaded, but this is likely out of the package's control.

Am I missing a different obvious solution somewhere?

Should authentication trait encrypt passwords?

One thing I found with the trait is that it wasn't encrypting passwords in a prePersist. This is pretty default behaviour, following a bcrypt mechanism for every project I've ever worked on - and is how Laravel's default mechanism checks that the password is valid.

Should we be setting up a prePersist on the Authentication trait that laravel-doctrine provides to make this part easier for users?

Documentation needs update - Working only with php > 5.5

Hi,

I get the following error with php 5.4.

syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

The documentation should specify this aspect.
The ::class constant is available only in Php 5.5.

screenshot_124
screenshot_123

Regards,
Andrei.

Generate database entities

You mind give me some direction of how i can generate entities in doctrine 2.* from existing databse schema?

Metadata Configuration

It seems to me, that the published configuration will be append to default configuration and don't overwrite the path definitions.

That will result in "missing app/models" if that dir don't exists.

Can anyone confirm that issue?

Can't install the package

Hi,
I have this following error when I try to install your package :

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - mitch/laravel-doctrine 0.3.4 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.3.3 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.3.2 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.3.1 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.3.0 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.2.4 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.2.3 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.2.2 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.2.1 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.1.2 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.1.1 requires doctrine/orm 2.5.* -> no matching package found.
    - mitch/laravel-doctrine 0.1 requires doctrine/orm 2.5.* -> no matching package found.
    - Installation request for mitch/laravel-doctrine 0.* -> satisfiable by mitch/laravel-doctrine[0.1, 0.1.1, 0.1.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4].

Custom Repository extending EntityRepository

Hi guys,

Disclaimer: I'm trying this on my version of Laravel 5 (yes I know it's not even beta). Please can someone confirm if this is or isn't the case on L4?

I have an Entity with a custom Repository. That custom repository class is extending the default Doctrine\ORM\EntityRepository.

When trying to use the entity in my app I immediately get the following error:

Unresolvable dependency resolving [Parameter #0 [ $em ]] in class Doctrine\ORM\EntityRepository

The cause seems to be that the $em argument in the EntityRepository constructor is not type hinted. Fixing this first case only leads to further unresolvable dependency issues with other non type-hinted params throughout the initialisation of EntityRepository so not workable (plus I'm hacking at the core Doctrine code).

Now, how best to get around this problem? Is my only option to manually bind each custom repository in the IOC?

Thanks

Soft delete cascade

Hi guys and sorry for my bad English.
I have create 2 entities, user and user_data, binded between them to "user_data_id" in user model.
This is the code in user model:

/**
 * @ORM\Entity
 * @ORM\Table(name="user", options={"collate"="utf8_general_ci", "charset"="utf8", "engine"="InnoDB"})
 * @ORM\HasLifecycleCallbacks()
 */
class User implements UserInterface {
    use Timestamps;
    use SoftDeletes;
....
    /**
     * @ORM\ManyToOne(targetEntity="UserData", inversedBy="user")
     * @ORM\JoinColumn(name="user_data_id", referencedColumnName="id", onDelete="CASCADE")
     */
    private $user_data;
...

And this is the code in user user_data model:

/**
 * @ORM\Entity
 * @ORM\Table(name="user_data", options={"collate"="utf8_general_ci", "charset"="utf8", "engine"="InnoDB"})
 * @ORM\HasLifecycleCallbacks()
 */
class UserData {

    use Timestamps;
    use SoftDeletes;

    public function __construct() {

        $this->users = new ArrayCollection();
    }
...

So, when I delete a record in user_data table from phpmyadmin, the related records in user table will be deleted. But when I perform deleting from code, "soft delete" method, updates the deleted_at column fine, but not also in related tables:

        $userDataRepo = $this->em->getRepository('UserData');
        $userData = $userDataRepo->findOneById(1);

        $this->em->remove($userData);
        $this->em->flush();

Some suggestion?

Doctrine 2.5

Defined dependency of doctrine 2.5 beaks the installation. There is no such version .

PHP 5.4 or 5.3

While Doctrine 2.4 and Laravel 4.1 work with PHP 5.3.7+, this wonderful package only works with PHP 5.4. I have the feeling that it can be made backwards compatible without losing functionality.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.