Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 11 03:40
    nicksagona closed #5
  • Jun 01 18:48
    nicksagona transferred #9
  • Jun 01 18:48
    nicksagona edited #5
  • Jun 01 18:48
    marshmanGit opened #5
  • Jun 01 00:57

    nicksagona on 5.3.3

    (compare)

  • Jun 01 00:55

    nicksagona on master

    Patch SqlSrv options array merge (compare)

  • Jun 01 00:55

    nicksagona on v5-dev

    Patch SqlSrv options array merge (compare)

  • Jan 14 17:57

    nicksagona on 5.3.2

    (compare)

  • Jan 14 17:57

    nicksagona on 4.5.11

    (compare)

  • Jan 14 17:42

    nicksagona on 4.5.11

    (compare)

  • Jan 14 17:40

    nicksagona on master

    Patch expression issue for NOT … (compare)

  • Jan 14 17:40

    nicksagona on v5-dev

    Patch expression issue for NOT … (compare)

  • Jan 12 14:54
    marshmanGit edited #9
  • Jan 12 14:50
    marshmanGit opened #9
  • Dec 14 2021 21:01

    nicksagona on 3.7.1

    (compare)

  • Dec 14 2021 21:00

    nicksagona on master

    Patch PHP 8 issue with named pa… (compare)

  • Dec 14 2021 20:58

    nicksagona on v3-dev

    Patch PHP 8 issue with named pa… (compare)

  • Oct 14 2021 17:04

    nicksagona on 4.5.10

    (compare)

  • Oct 14 2021 17:03

    nicksagona on 4.5.10

    (compare)

  • Oct 14 2021 17:02

    nicksagona on v4-dev

    Patch dirty save (compare)

Nick Sagona
@nicksagona
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);
so the 3 params for the following line of code:
$text->setAlignment(Page\Text\Alignment::createCenter(50, 562, 15));
are $leftX, $rightX, and $leading
and those set the left and right bounds for the string of text to be contained and centered in.
document.pdf
That's the PDF that was created with that code sample. Let me know if that helps.
DrewM
@AndrewM
Yes, that helps! Thanks.
Nick Sagona
@nicksagona
Great! No problem. I'll try to carve out some time soon to update the docs to demo how the alignment and wrap features work for Pop PDF
FYI, if interested, there's also some experimental DOM/HTML rendering features in Pop PDF as well, but that needs a bit of work to be finished off (namely, I left off working on rendering tables)
DrewM
@AndrewM
Are there controls for a header/footer on every page with Pop PDF?
And lastly (I think).... what happened to the direct download of the latest versions of Pop PHP Framework? The website references links...but I cannot find a full-source download anywhere.
Nick Sagona
@nicksagona
so to answer the first question, there is nothing directly available for controlling headers/footers in Pop PDF at this time. It's something that could be considered, if kept pretty simple. But the main concern would be that it's something like that would be fairly specific/custom to the PDF you're looking to generate. I've handled it in my own applications by writing a little helper method that would generate all of the header and footer content formatted exactly as I need it to be. But they were fairly complex headers and footers with multiple lines of text, page numbers, images, etc.
And your second question is that, the decision was made about a year ago or so to no longer support or provide to direct download option. It was just one more thing to manage and the stats showed just about everyone using composer these days, so it seemed like a good time to do away with it. Using composer should be the preferred way to get Pop and/or any of its supporting components.
Nick Sagona
@nicksagona
Ah - I've corrected the docs that reference the stand-alone download. That's been removed as it is no longer supported.
Sorry for the confusion there.
Gideon Dannang
@gcd445_twitter
hi , is there an updated pop-bootstrap, or a project w/ pop-auth and pop-acl?
Nick Sagona
@nicksagona
Sorry, unfortunately pop-bootstrap is deprecated and no longer supported. There's currently no tutorial or sample app that demo's auth/acl, but it could be considered.
Maikel Nieves Matamoros
@mikethewolf83
Hi...I am new to this framework. How can I access to database from model without extending model to Record?
Nick Sagona
@nicksagona
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
Maikel Nieves Matamoros
@mikethewolf83

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

Nick Sagona
@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:
$application->services()->set('database', [
    'call'   => 'Pop\Db\Db::connect',
    'params' => [
        'adapter' => 'mysql',
        'options' => $options
    ]
]);
and then anywhere in your application you can access the DB service like:
$db = $application->services['database'];
Maikel Nieves Matamoros
@mikethewolf83

@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?

Nick Sagona
@nicksagona
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.
If you have a DB service registered with the application, you can also access it globally via the static service container class.
Also, the benefit of using the DB Record class, is the DB adapter is registered statically with the Record class and is available globally. Plus the Record class abstracts away a lot of common SQL functionality
via the Active Record pattern (with a little bit of Table Gateway)
Maikel Nieves Matamoros
@mikethewolf83

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.

Nick Sagona
@nicksagona
yes, while the active record and query builder does support simple joins, typically complex queries can (and should) just leverage the DB adapter and writing and executing the SQL directly
Maikel Nieves Matamoros
@mikethewolf83
Hi everyone I'm looking for an example of pop-auth with pop-acl....is there any? I can't figure it out. Greetings
Florian Masy
@fmasy

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 :)

Nick Sagona
@nicksagona
hello - sure
so if you want to have your routes served from under a base URI, you can do this to your routes config:
    'routes'   => [
        '/poptutorial' => [
            '/' => [
                'controller' => 'Tutorial\Controller\IndexController',
                'action'     => 'index'
            ],
            '/post' => [
                'controller' => 'Tutorial\Controller\IndexController',
                'action'     => 'post'
            ]
        ],
        '*' => [
            'controller' => 'Tutorial\Controller\IndexController',
            'action'     => 'error'
        ]
    ],
by nesting it like that, you can now access routes like http://localhost:8000/poptutorial/post
Florian Masy
@fmasy
Oh, thank you a lot Nick. I had completely missed that from the documentation.
Nick Sagona
@nicksagona
No problem
DrewM
@AndrewM
I just upgraded from 4.1 to 4.6.... my application is throwing these errors even though the documentation still seems in line with what I have and has already been working... any insight? - "PHP Fatal error: Uncaught Error: Class 'Pop\Http\Request' not found"
DrewM
@AndrewM
@nicksagona - just to be clear... the application worked fine on the 4.1 code base. Thanks!
Nick Sagona
@nicksagona
Hey @AndrewM so minor BC break - the code under the pop-http repo was refactored slightly to better separate the "server" and "client" classes and code base
so Pop\Http\Request and Pop\Http\Response no longer exist and have been replaced with Pop\Http\Server\Request and Pop\Http\Server\Response
DrewM
@AndrewM
@nicksagona Thanks. By doing a find/replace I've been able to make some progress on that. I'm finding, however, that there were at least a couple other major shifts. 1. $asResult = AS_ARRAY, AS_OBJECT, AS_RECORD and right now the Session component is not storing what it used to. I was getting a db record and then throwing it ->toArrayObject() - which also no longer exists.
Nick Sagona
@nicksagona
yea you're def going to want to check out the changelog:
v4.5 was a pretty big refactor in a number of components
DrewM
@AndrewM
@nicksagona I'm getting a high number of these every day.... any thoughts or suggestions to trouble-shoot? "PHP Fatal error: Uncaught Pop\Db\Adapter\Exception: Error: 2006 => MySQL server has gone away in /popphp/pop-db/src/Adapter/AbstractAdapter.php:394"
Nick Sagona
@nicksagona
That would suggest there might be an issue with the MySQL server or the PHP server configuration to access MySQL via PHP?