require_once 'vendor/autoload.php'; use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\EntityManager; $isDevMode = true; $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.'/src'), $isDevMode); // database configuration variables $dbParams = array( 'driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'my_db', ); $entityManager = EntityManager::create($dbParams, $config);
use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="users") */ class User { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $name; // ... getters and setters }In this code example, we are defining a User entity that corresponds to a 'users' table in the database, with an ID and name column. We use Doctrine annotations to specify various properties of the entity, including its table name and column types. Overall, Doctrine is a popular PHP ORM library that provides a powerful set of tools for working with databases in an object-oriented way.