A: Composer offers a handy installer for windows users. It's available from their download page. (When installing, choosing the option to add context menus can be very helpful.)
A: You should have two copies of your UserFrosting project. One you keep on your local dev machine, and the public one people will be using. Your local copy will be the place where you do all your coding and testing. Once it's perfect, you upload to the public server. With this method you leave little to no chance of accidentally breaking the site that has active users.
A: These files contain the "View" for your site. All of your HTML sits in these files. Why the "twig" extension, you ask? Because these files hold more than vanilla HTML. You can use Twig code to perform basic programmatic tasks like iterating over arrays, using variables, and more of the basics.
A: You don't. UserFrosting is based on and requires that you follow the Model-View-Controller format. Anything you need to do with PHP is probably best suited for your controller or model, not the view. In the controller you will generate the necessary variables for your twig template to render.
A: Okay, there might already be an extension to do what you need. If there isn't a twig extension for what you need, you can write your own filter like so (this would sit in the setupTwig() function within /models/UserFrosting.php
):
$twig = $app->view()->getEnvironment();
$twig->addFilter(new \Twig_SimpleFilter('fancy_quoted', function ($input) {
return "“".$input."”";
}));
This filter just adds those fancy quotes (the kind that makes copying and pasting code a headache) around your text,
{{ "Here is my whole quote" | fancy_quoted }}
=> “Here is my whole quote”
A: Use a service that provides ssl certificates for an https connection. They are free nowadays with letsencrypt, cloudflare, and other providers.
A: These are dynamically generated files.
templates/themes/THEME_NAME/
.configJS()
function within UserFrosting's BaseControllerA: The primary group is the main group that the user is assigned to. This controls certain things like their theme. The other groups that a user belongs to are more like "roles" that offer more granular controls of users' abilities.
A: Try tutorial 1, Creating a New Page.
A: Try tutorial 2, Processing a Form Submission.
A: Try tutorial 3, Extending the Data Model.
" There's information all over the web and it's about time it all landed in one place!"
A: See the stackoverflow question and answer
A: If your posted data looks something like:
$post = [
'id': 25,
'token': sometokenhere,
'an_array_of_options': [
'title': 'This is my item',
'desc': 'This item is great'
]
];
..then two schemas are needed: 1 that validates just the first layer (so, it would only do the id
field), then another for the an_array_of_options
. You will need to run the validator twice (one for each schema)
A: Twig is configured through Slim\Views\Twig. Options you would normally pass to new Twig_Environment()
are instead passed to parserOptions in Slim\Views\Twig. To access the parserOptions, you'll need to modify the "Instantiate the Slim application" section of config-userfrosting.php
$app = new \UserFrosting\UserFrosting([
'view' => $view = new \Slim\Views\Twig(),
'mode' => 'dev' // Set to 'dev' or 'production'
]);
$view->parserOptions = array(
'debug' => true
);
$view->parserExtensions = array( //similar to parserOptions, this line is necessary to enable debug (and dump())
'Twig_Extension_Debug'
);
A: UFModel
disables timestamps by default. Your data model most likely extends from this so you'll need to reenable them on a model-by-model basis. To do this, add the following line within the class that defines your model:
public $timestamps = true;
A: $app->config('parameter')['deeper parameter']
so if you want to find out the "user_id_master", just do $app->config('user_id_master')
. If you want to find the site's public uri, use $app->config('uri')['public']
.
A: In config-userfrosting.php, change 'mail' => 'smtp'
to 'mail' => ''
A: Most of UF's functionality can be understood by traversing through the code. The best way to do this is not to open each file and search through it. Rather, use a text editor that allows you to search for text within a set of folders or search through the code on github. (eg: How does UF send emails?) This works really well because both UF and the many vendors that provide code have included either helpful comments or named the functions/classes in a manner that just makes sense.
What is probably happening: You are submitting a form without including the CSRF token. Most of the time you'll be submitting forms via AJAX. To do this, you'll generally want to use the ufFormSubmit function to get your form ready. See it below
// Process a UserFrosting form, displaying messages from the message stream and executing specified callbacks
function ufFormSubmit(formElement, validators, msgElement, successCallback, msgCallback, beforeSubmitCallback)
A great and very simple example of this function in use is on the Login page.
Q: I'm using the ufFormSubmit function but it's still not working. What now?
A: There are two things to check at this point. Go to the page in your browser where the form should be and view the source. Go to the lines where ufFormSubmit sits and check that the validators and any other server-generated content rendered correctly. At the same time, you'll want to check your browser's console for any javascript errors. If there are other javascript errors on the page you may not be able to use ufFormSubmit even if your implementation is correct. If that's the case, you'll need to resolve those other javascript errors first.
Lastly, you'll want to monitor what happens when you POST your form by using your browser's network monitor. Check the response code and the parameters sent. Is the CSRF token present?
With time, most errors can be hammered out with a bit of investigation and elbow grease. Here are the steps I take when investigating a random error that I have no idea about:
Ever heard of GIMF? If not, google it. Seriously though, much of UserFrosting's environment is built on code provided by 3rd party vendors and it's your due diligence to learn from their documentation. So, if you are coming up with no google results for "userfrosting here's my issue" you might just try "here's my issue". You can also double check in the error log for which vendor the error occurs with and include this in your search (eg: "laravel querybuilder error").
Another great place to look is in UserFrosting's chat history. You can also look in our old chat room, at https://gitter.im/userfrosting/UserFrosting
.