Fluid and Frozen
RedBeanPHP has two modes, fluid and frozen.
As you have seen in the previous chapters, RedBeanPHP will keep changing the schema to fit your needs, this is what we call 'fluid mode'.
While this is great for development you don't want this to happen on your production server. That's why you need to freeze the schema before you deploy your application. To freeze your app, put R::freeze( TRUE ) at the beginning of your script, like this:
R::freeze( TRUE );
After freezing the schema, open your database client and inspect the schema RedBeanPHP has created for you. You can now refine it where necessary, i.e. add some indexes, change some columns, add or change constraints and more.
Always review the schema generated by RedBeanPHP and allow yourself some
time to refine it.
Do not change the table or column names though, these are part of the RedBeanPHP conventions. Instead I recommend to inspect and refine column types ( maybe a bit too wide ? ), indexes and foreign key constraint settings.
Partial freezing (Chill mode)
It's also possible to only lock the schemas of several types of beans, for instance to lock the schemas of bean types 'book', 'page' and 'book_page' use:
R::freeze( ['book','page','book_page'] );
This makes RedBeanPHP operate in fluid mode, but those tables will not get modified. To reset, pass an empty array.
Learn how to use the debugging tools.
The Deepfreeze script is a PHP script available from the Github repository. This script will remove all fluid parts of RedBeanPHP, i.e. all the schema modifying code. This will essentially disable fluid mode permanently and make the rb.php file more compact. This script is experimental though because it's quite hard to test. To run the DeepFreeze script:php deepfreeze.php
The DeepFreeze script will search for an rb.php file in the current folder and generate a rbf.php file in the same folder.
back to main menu
RedBeanPHP Easy ORM for PHP © 2019 Gabor de Mooij
() and the RedBeanPHP community
(credits) - Licensed New BSD/GPLv2 -
RedBeanPHP, the power ORM for PHP since 2009.
RedBeanPHP is part of the GWorx Application Server Platform. GWorx Application Server is a product of Gabor Software © copyright 2019. Learn more about GWorx.