To contribute to this documentation, please submit a pull request to our learn repository.
php bakery bake
.If installation of npm dependencies fails, see npm to ensure npm is correctly installed and updated. You may need to change npm permissions.
This is an indication that asset build failed or you missed a step in the installation process. Try running the installer again withphp bakery bake
and check for any error messages.
UserFrosting uses a dynamic routing system for serving assets in a development environment. For this to work on an Apache webserver, mod_rewrite
needs to be enabled, and you need to give Apache permission to use the .htaccess
file in public/
.
mod_rewrite
If you have shell access to your server, please take the following steps (from Stack Overflow):
sudo a2enmod rewrite
sudo service apache2 restart
If this still does not work, you may need to change the override rule in your Apache configuration to allow Apache to use UserFrosting's .htaccess
file.
.htaccess
apache2.conf
, http.conf
, or 000-default.conf
). In XAMPP, for example, this file is located at XAMPP/etc/httpd.conf
.Directory /var/www/
Override None
to Override All
You may need a server admin to do this if you are using shared hosting.
If you get an error stating rewrite module is not found, then your userdir
module is probably not enabled. To enable it:
sudo a2enmod userdir
For more information, see this blog article.
The "There is no class mapped" error occurs when you attempt to use the dynamic class mapper with an identifier that has not been successfully mapped to a class name. If you are sure that you defined the mapping in your Sprinkle's ServicesProvider
class, it is likely that UserFrosting is simply not even finding your ServicesProvider
class itself. This is usually due to using an incorrect namespace for your Sprinkle.
It's important to understand that UserFrosting uses a very strict, case-sensitive naming convention for Sprinkle namespaces. UserFrosting will convert your Sprinkle's directory name to studly caps when it builds the fully qualified namespace where it expects your ServicesProvider
and Migration
classes to be found. If your Sprinkle's namespace does not match what UserFrosting is expecting, it will not find and load these classes. This will not cause an error directly, but will manifest in other parts of your code that depend on these classes to be located successfully.
Studly caps uses the following code to convert your Sprinkle directory name to an expected namespace:
$value = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $value)));
As you can see, all -
and _
characters are first converted to spaces. Then, PHP's ucwords
function is used to capitalize each word. Finally, the spaces are removed.
Some examples:
Sprinkle directory | Sprinkle namespace |
---|---|
site |
Site |
pokemon-master |
PokemonMaster |
pokemonmaster |
Pokemonmaster |
pokemonMaster |
PokemonMaster |
Pokemonmaster |
Pokemonmaster |
PokemonMaster |
PokemonMaster |
Pokemon-Master |
PokemonMaster |
We strongly recommend using only lowercase words separated with -
for Sprinkle directory names.
You may need to re-run Composer if you change your Sprinkle directory path or namespace. On certain operating systems with case-insensitive filesystems, Composer may not update the directory -> namespace mappings correctly. You may need to completely erase your
app/vendor
directory and re-runcomposer install
in these cases.
UF_MODE='production'
.The production
mode, by default, enables FastRoute's route caching. This can result in route definitions not being updated in the cache during production. To resolve this, you should clear the route cache in app/cache/routes.cache
.