Unlikely you will find an OS solution for that.
You generally have 2 parts of your project:
1) Database for storage of generated items + structure of the item entity
2) Script to generate random items based on given logic (luck in this case)
1. If you decide to use Relational DB (MySQL), the structure could be like:
item:
-id - PK
-rarity (enum: 1-green, 2-blue, 3-yellow) //although i suggest you stick to the blizzard colors, they are much intuitive for most gamers nowadays
-quality (int 2) //0-20
-generated_at (datetime)
item_property:
-item_id (foreign key pointing to item.id)
-property_id (foreign key pointing to property.id)
property:
-id - PK
-name (string) // example: artisan's
-attribute_id (foreign key pointing to attribute.id) //ex. strength
-value (integer) // example: 10
-type: (smallint) // 1-prefix, 2-suffix, 3-base or whatever you want it to be
attribute:
-id - PK
-name (string) //example: strength
Note this is very very basic structure, you can introduce skills, character-based properties, set items etc etc.. but that is a topic of another discussion.
2. You make the script to roll a random rarity, then create an item based on that. The logic here again can be very simple and very complicated (for example to roll for specific character class specific properties only).
The code itself is different based on whether you want to use a framework or not. I personally havent coded pure php in a while, and find it ugly right now. It is much better to define entities and hydrate them with random data.
For the logic itself:
1) $rarity = rand(1,100); //generate random number
2) check $rarity // 1-60 - normal, 60-90 -rare, 90-100 -legendary (or any other way you decide)
3) based on rarity (from item entity in the DB) you generate the accurate prefix/suffix mode and depending on whether you want to have always one suffix / one prefix or can be random you populate the data. You can get random skill from the skills entity and assign to it random value, depending on your requirements again.