nicksagona on 5.3.3
nicksagona on master
Patch SqlSrv options array merge (compare)
nicksagona on v5-dev
Patch SqlSrv options array merge (compare)
nicksagona on 5.3.2
nicksagona on 4.5.11
nicksagona on 4.5.11
nicksagona on master
Patch expression issue for NOT … (compare)
nicksagona on v5-dev
Patch expression issue for NOT … (compare)
nicksagona on 3.7.1
nicksagona on master
Patch PHP 8 issue with named pa… (compare)
nicksagona on v3-dev
Patch PHP 8 issue with named pa… (compare)
nicksagona on 4.5.10
nicksagona on 4.5.10
nicksagona on v4-dev
Patch dirty save (compare)
use Pop\Pdf\Pdf;
use Pop\Pdf\Document;
use Pop\Pdf\Document\Font;
use Pop\Pdf\Document\Page;
// Create text object
$string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec ligula ligula. Cras at dictum nibh. Nulla pulvinar accumsan arcu vitae vulputate. Cras pretium libero sit amet lobortis sagittis. Aliquam interdum vitae eros ut porttitor. Sed maximus purus vitae metus euismod imperdiet. Aliquam varius ultrices augue ut consequat. Aliquam feugiat ipsum eleifend ipsum vulputate feugiat. In posuere velit id magna porta viverra. Morbi diam mauris, porta eget felis ac, tincidunt malesuada dui. Donec vel urna id elit egestas vestibulum eget ac erat.';
$text = new Page\Text($string, 12);
// Add bounding alignment object
$text->setAlignment(Page\Text\Alignment::createCenter(50, 562, 15));
// Create a page and add the text to it
$page = new Page(Page::LETTER);
$page->addText($text, Font::ARIAL, 50, 650);
// Create a document, add the font to it and then the page
$document = new Document();
$document->addFont(new Font(Font::ARIAL));
$document->addPage($page);
// Pass the document to the Pdf object to build it and output it to HTTP
$pdf = new Pdf();
$pdf->outputToHttp($document);
$text->setAlignment(Page\Text\Alignment::createCenter(50, 562, 15));
$leftX
, $rightX
, and $leading
Hi - sure, you can just use the database adapter directly, via basic queries or prepared statements with bound parameters. Check out the docs here: https://pop-php-framework.readthedocs.io/en/latest/user_guide/databases.html#querying-a-database
Thanks Nick, but is there a way to avoid doing this:
$db = Pop\Db\Db::connect('mysql', $options);
I mean, a way to get the default database configuration instead of setting a config here
$application->services()->set('database', [
'call' => 'Pop\Db\Db::connect',
'params' => [
'adapter' => 'mysql',
'options' => $options
]
]);
$db = $application->services['database'];
@nicksagona
well a typical way to go is set the database as a service within the application. Have it wired up one time at the beginning of the app's lifecycle and then call that DB service as you need it. For example, you could have something like:
Ok, agreed...sorry for my insistence, but for example in app\src\Module.php there is:
public function register(Application $application)
{
parent::register($application);
if (isset($this->application->config['database'])) {
$this->initDb($this->application->config['database']);
}
if (null !== $this->application->router()) {
$this->application->router()->addControllerParams(
'*', [
'application' => $this->application,
'request' => new Request(),
'response' => new Response()
]
);
}
return $this;
}
I noticed:
$this->application->config['database']
is there a way to use something like this in my model?
well the model would have to be application-aware in order to access that. Either by passing the app object into the model's constructor, or into the method you're calling on the model.
Ok okay, in my case I need to do a complex query with joins to three MySQL VIEWs, which have no ID field. This Active Record implementation I don't think will allow me to do it with the query builder.
Hello everybody,
I'm trying to figure out how to configure my apache virtualhost to serve a pop application when the url to access it will have a "prefix" in the request uri.
I'll using the popphp tutorial application as an example => https://pop-php-framework.readthedocs.io/en/latest/tutorial_application/index.html
It has three routes defined: / (root), /post and * (everything else)```
It is installed under D:\dev\pop-tutorial
My virtualhost has DocumentRoot pointing to D:\dev\pop-tutorial\public and I defined a Directory to that same location with the following rewrite rule (the same that are in the .htaccess in the public directory of the application).
So my virtualhost definition look like this:
<VirtualHost *:80>
ServerName pop-tutorial
DocumentRoot "D:\dev\pop-tutorial\public"
<Directory "D:\dev\pop-tutorial\public">
Options Indexes FollowSymLinks
Require all granted
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>
</VirtualHost>
If I request http://localhost/post it will route as expected.
But how I can make it works so that I can access it through http://localhost/poptutorial/post ?
In that case the $_SERVER["REQUEST_URI"] will be /poptutorial/post and it doesn't match any routes.
If you have some ideas they are very welcome :)
'routes' => [
'/poptutorial' => [
'/' => [
'controller' => 'Tutorial\Controller\IndexController',
'action' => 'index'
],
'/post' => [
'controller' => 'Tutorial\Controller\IndexController',
'action' => 'post'
]
],
'*' => [
'controller' => 'Tutorial\Controller\IndexController',
'action' => 'error'
]
],
Pop\Http\Request
and Pop\Http\Response
no longer exist and have been replaced with Pop\Http\Server\Request
and Pop\Http\Server\Response