Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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)

  • Oct 14 2021 16:57

    nicksagona on master

    Patch dirty save/set function (compare)

  • Oct 14 2021 16:57

    nicksagona on v5-dev

    Patch dirty save/set function (compare)

  • Aug 18 2021 16:37
    nicksagona closed #23
  • Aug 18 2021 16:37

    nicksagona on 3.6.1

    (compare)

  • Aug 18 2021 16:36

    nicksagona on master

    Patch setValue issue with Check… (compare)

  • Aug 18 2021 16:35

    nicksagona on v3-dev

    Patch setValue issue with Check… (compare)

  • Aug 12 2021 14:54
    B0bbyD0llar opened #23
Nick Sagona
@nicksagona
here's some of the work I've done on a v4-dev branch so far: https://github.com/popphp/pop-http/tree/v4-dev/src
John Esteban Astete Arambarri
@johnnestebann
I'm active on some developments with version 4.1.0 and 4.5.0-beta-4, but I think you're right, it's better understood
Nick Sagona
@nicksagona
ok thanks for the feedback... I think the worse case is people will have to add \Server to their use statements - for example, changing from Pop\Http\Request to Pop\Http\Server\Request
Nick Sagona
@nicksagona
Ok v4 of pop-http is complete... not live yet... I haven't cut a release yet. If anyone wants to look it over, you can do so over on the v4-dev branch here: https://github.com/popphp/pop-http/tree/v4-dev
Nick Sagona
@nicksagona
Ok Pop PHP Framework 4.5.0 beta-5 was just released. The framework and all corresponding components use the newly re-factored pop-http v4. I believe BC breaks have been kept to a minimum and the main thing that will have to change is any references to Pop\Http\Request and Pop\Http\Response will have to change to Pop\Http\Server\Request and Pop\Http\Server\Response, respectively
Furthermore, those of you using pop-kettle, make sure you have v1.3.0 which now comes with the proper updates to the underlying templates to utilize pop-http v4.
Thanks!
John Esteban Astete Arambarri
@johnnestebann
Hi! I'm using the 4.5 beta-5, and I having some troubles with Relationships and Associations. I have this relationships: movie hasOne quality and quality hasMany movie, but when I wanna show the movie list with his qualities, it show me a bad list
Nick Sagona
@nicksagona
Hey - I'm looking into this right now
Nick Sagona
@nicksagona
so here's some quick code to illustrate how it should work:
assume 2 classes like this:
class Movies extends Pop\Db\Record
{
    public function qualities()
    {
        return $this->hasMany('Qualities', 'movie_id'); // 'movie_id' is the FK 
    }
}
class Qualities extends Pop\Db\Record
{
    public function movie()
    {
        return $this->belongsTo('Movies', 'id'); // 'id' is the primary key that is used to get the parent relationship
    }
}
Here's the results of the following queries:
$movie = Movies::findById(1);        // Get a single movie
$qualities = $movie->qualities();  // Get all qualities of that movie
print_r($movie->toArray());
print_r($qualities->toArray());
this gives you:
// Movie
Array
(
    [id] => 1
    [title] => Avengers
)
// Qualities of the movie
Array
(
    [0] => Array
        (
            [id] => 1
            [movie_id] => 1
            [type] => Great
        )

    [1] => Array
        (
            [id] => 2
            [movie_id] => 1
            [type] => Exciting
        )

)
And in reverse:
$quality = Qualities::findById(1);       // Get a single quality
$parentMovie = $quality->movie();  // Get that quality's parent movie
print_r($quality->toArray());
print_r($movie->toArray());
and that gives you:
// Quality
Array
(
    [id] => 1
    [movie_id] => 1
    [type] => Great
)
// Movie the quality belongs to
Array
(
    [id] => 1
    [title] => Avengers
)
so the DB schema is a table movies and a table qualities with a FK qualities.movie_id referencing back to movies.id
Nick Sagona
@nicksagona
you set up the helper functions in the Record classes like above, and you should be able to get the child relationships (hasMany) and parent relationships (belongsTo or hasOne)
Let me know if this makes sense and is working for you in this way. Thanks.
Nick Sagona
@nicksagona
Hey Everyone - Pop PHP Framework v4.5.0 has now been officially released. Many upgrades and improvements. You can check them out in the CHANGELOG: https://github.com/popphp/popphp-framework/blob/master/CHANGELOG.md
John Esteban Astete Arambarri
@johnnestebann
Thanks!
John Esteban Astete Arambarri
@johnnestebann
Hi! Now I have all my projects with 4.5 version without complications on upgrade!
Nick Sagona
@nicksagona
nice! good to hear!
Nick Sagona
@nicksagona
Hey everyone! The first draft of documentation for v4.5.0 was just released https://docs.popphp.org/
It covers A LOT more of the functionality that was previously missing in the earlier versions of the docs, plus adds coverage of the newer features.
Baalzebul
@Baelzebul_twitter
Is there any full example of a record class based on some table nuts to bolts
Nick Sagona
@nicksagona
The docs over at https://docs.popphp.org/ were recently just updated. The Database / Active Record section under User Guide might be helpful: https://pop-php-framework.readthedocs.io/en/latest/user_guide/databases.html#active-record
petkovic-v
@petkovic-v
Is there a way to generate dynamically a url for hyperlinks (href attribute) using the route object. Is there in PоpPhp a route name to generate a url over its name as it is done in Laravel or Slim framework?
Nick Sagona
@nicksagona
Yes I believe you are asking about dynamic routing, which is possible. Check out the docs here and let me know if that's what you're looking for: https://pop-php-framework.readthedocs.io/en/latest/getting_started/routing.html#dynamic-routing
petkovic-v
@petkovic-v

Thank you, Mr. Nick Sagona, for answering my question quickly. However, I don't think that's what I wanted to ask.

For example, in Laravel, a route is defined as follows:

Route::get('user/{id}/profile', function ($id) {
//
})->name('profile');

and to generate the url address (for href in <a>) the code is used:

$url = route('profile', ['id' => 1, 'photos' => 'yes']);

// /user/1/profile?photos=yes

Can something similar be done in popphp ?

Nick Sagona
@nicksagona
oh you're talking about basic routing parameters? perhaps this? https://pop-php-framework.readthedocs.io/en/latest/getting_started/routing.html#dispatch-parameters
you can definitely create routes with defined parameters like
/users/:id or /users[/:id]
(2nd one is optional)
and that's supported for console app routing as well
and then those routes can map to callable items (closures, actions in a controller, etc) that take those parameters in like:
function ($id) { }
but as far as the URL/HREF generation
Nick Sagona
@nicksagona
that's not really available in the core popphp components
but something may be possibly wired up in the MVC between the core popphp components (router, controller) and the view component
petkovic-v
@petkovic-v

Ok. Understand . Sorry if I'm holding you back too much and thanks again for trying to help me. I read all your documentation about the PopPHP framework in the last two days and I didn't find what I asked as a question here. The PoPPHP framework is very nice and I would like to move on from Laravel to use it.

Let me try to ask you like this. In PopPHP routes we can define as follows:

$config = [
'routes' => [
'/products/:id' => [
'controller' => 'MyApp\Controller\ProductsController',
'action' => 'index',
'controllerParams' => [
'id' => 789
]
]
]
];

$app = new Pop\Application($config);

We have a defined route in the code above that responds to the url address /products/:id. The Route object has the properties controller, action, and controllerParams (but as far as I can see property name does not exist as in Laravel for the reverse process - generating url addresses via route object).

In PoPPHP, I assume that this route can be accessed using the code:

$myRoute = $app->router()->getRoutes()['/products/:id'];

There was a possibility to generate a url address from the route (for example for the href Edit button in the html table in the 3rd row the generated url address would be).

/products/3 - for dispaly details page for product 3

Thank you for all the answers you have given me. Greetings and I wish you all the best.
Nick Sagona
@nicksagona
No problem - and you're not holding me back at all. Happy to help. I'm currently at work right now, but I will take a look at the example you just posted and see if I can get an answer for you later this evening.
Nick Sagona
@nicksagona
So for clarity, you are asking about generating the URLs for the HREF attribute in A tags inside of an html view, correct? For example, a simple table like:
<table>
    <tr>
        <td><a href="/profile/1">Edit</a></td>
        <td>Profile 1</td>
    </tr>
    <tr>
        <td><a href="/profile/2">Edit</a></td>
        <td>Profile 2</td>
    </tr>
    <tr>
        <td><a href="/profile/3">Edit</a></td>
        <td>Profile 3</td>
    </tr>
</table>
and you want to use the router to generate those URL strings in that HTML there, is that correct?