craftcms / craft Goto Github PK
View Code? Open in Web Editor NEWComposer starter project for Craft CMS.
Home Page: https://craftcms.com
License: BSD Zero Clause License
Composer starter project for Craft CMS.
Home Page: https://craftcms.com
License: BSD Zero Clause License
Composer's config.platform.php
is set to 7.0 by default. This overrides the system's PHP Version, and prevents dependencies that requires newer versions of PHP from being installed.
Why is it set at all?
Hello,
I followed all instructions on the documentation to install craft.
Everything worked until I do: ./craft serve/index and then go to the specified URL. I get "Template not found: dashboard"
The templates directory only has an index.html file in it. Is this the problem?
Any ideas?
This seems like a perfect candidate to be a Template repository: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-template-repository
Hi,
I was wondering if the following setup is a good practice.
In my .env file I defined a single rootUrl var which contains the site root url like this:
ROOT_URL="https://www.mydomain.test"
In the general.php config file i've created an alias (@rootUrl) that contains the ROOT_URL env var value:
'aliases' => [ '@rootUrl' => getenv('ROOT_URL'), ],
Then I define my craft sites as following (multilingual site), each site BASE URL is constructed with the rootUrl and a language:
Advantages
Disadvantages
Does this logic makes sense or is it generally a bad idea to use aliases for the site BASE URL setting?
Thanks in advance,
Thomas
With Composer 2.2+ composer plugins need a verification
https://getcomposer.org/doc/06-config.md#allow-plugins
Consider to add this config section, to avoid the prompt when installing the dependencies the first time:
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true,
"craftcms/plugin-installer": true
}
},
When you add a file extension to the allowed uploads/assets but output {{ file.type }}
it can return 'undefined'. I propose that the config setting for allowedFileExtensions and extraAllowedFileExtensions be in the format ['extension'=>'type', … ]
where type is optional or make it an array of tuples [['ext'.'type'],['ext,'type']]
, whatever implementation you like for backwards compatibility.
for example…
'extraAllowedFileExtensions' => [
'pub' => 'publisher',
'bz' => 'compressed'
]
// tuple-style
'extraAllowedFileExtensions' => [
['pub', 'publisher'],
['bz', 'compressed'],
]
perhaps this can be extended to include mimetypes too to add to Yii's getMimeTypeByExtension helper that it looks like Craft uses.
The .env
uses ENVIRONMENT
, while the CMS uses CRAFT_ENVIRONMENT
. If the example env file is used, the environment variable will have no effect. Not sure, which one is the right.
https://github.com/craftcms/craft/blob/master/.env.example#L2
https://github.com/craftcms/cms/blob/develop/bootstrap/bootstrap.php#L104
Hi,
I'm trying to setup acceptante tests using Codeception and email part of craft\test\Craft module.
However, when using the seeEmailIsSent
assertion, the following Exeception is thrown:
[TypeError] Return value of craft\test\CraftConnector::getEmails() must be of the type array, null returned
For some reason, the return statement doesn't seem to return the expected array.
I've tried various mailer configurations with no success.
... and change/remove the platform php 7.0 thingy.
😻
Unless I’m missing something it’s not really practicable to use 'mysql' in one environment and 'pgsql' in another.
Line 12 in f5c0828
I'm trying to install CraftCMS (with composer create-project method) for the first time, and appear to have gone through all the steps on the installation guide - https://docs.craftcms.com/v3/installation.html#step-1-download-craft - yet I'm getting an Exception.
HTTP 503 – Service Unavailable – craft\web\ServiceUnavailableHttpException
Here is the line (509 in /var/www/craft/vendor/craftcms/cms/src/web/Application.php) that's throwing the exception:
// Should they be accessing the installer?
if (!$isInstalled) {
if (!$isCpRequest) {
throw new ServiceUnavailableHttpException();
}
Below is the call stack:
craft\web\ServiceUnavailableHttpException in /var/www/craft/vendor/craftcms/cms/src/web/Application.php:509
Stack trace:
#0 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(184): craft\web\Application->_processInstallRequest(Object(craft\web\Request))
#1 /var/www/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#2 /var/www/craft/web/index.php(21): yii\base\Application->run()
#3 {main}
I'm using v3.0.24 as far as I can see:
- Installing craftcms/cms (3.0.24): Downloading (100%)
As I haven't even got started with the CMS, I don't really know what more info to give - or where to go from here. The .env file has been copied, there really is no more instruction to do anything. Any ideas?
After working with Craft 3 for a while and contributing to craftcms/cms
a bit recently, I know the difference between craftcms/craft
and craftcms/cms
.
However, for newcomers to Craft 3 and to composer in general, the very similar package naming can be confusing. If the name of the package would reflect the purpose it would help. Here are my suggestions:
DotEnv\DotEnv::create
should be Dotenv\Dotenv::create
Usage:
@khalwat has a good template already
https://github.com/nystudio107/craft/blob/master/.gitignore
Running composer create-project craftcms/craft [directory]
currently throws a DbConnectException
.
setup/welcome
is trying to access the DB, which of course wouldn't be available yet. Here's the full error + stack trace, after composer finishes autoload generation.
Package Version: 1.0.43.2
OS X 10.13.6
This call (new Dotenv\Dotenv($root))->load()
fails when no .env file is present. Here is the exception:
Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file
It's used in web/index.php
and in the craft
binary. There are two workarounds I can think of:
getenv('CRAFT_ENV') != 'production'
This is not really an issue, more of a discussion.
Would adding a Dockerfile
or docker-compose.yml
be an option/pull request that would be considered? Meaning that if a docker-compose.yml
file, that contained an official PHP, MySQL and Postgres configuration, were to be added to this repository - would this be worth it to anyone?
Even if the end result is that the developer/project/installer decides not to use Docker, it would be a painless addition and take a minimal amount of effort to remove from their installation.
A quick example, not tested at all, would be a docker-compose.yml
file that looks something like this:
version: '2'
services:
craftcms:
image: php/7.0-apache
ports:
- "80:80"
depends_on:
- mysql-server
links:
- mysql-server
volumes:
- ".:/var/www"
env_file: .env
mysql-server:
image: mysql/5.7
ports:
- "3306:3306"
volumes:
- "./storage/database:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: SuperLongPassword!
MYSQL_DATABASE: dev_craftcms
MYSQL_PASSWORD: Password1!
MYSQL_USER: craftcms
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
Getting error message "craft\services\Assets::getThumbUrl(): Return value must be of type string, null returned" when trying to open a cp page which should have access to an asset with broken index if the rendered preview is not present
What are the gitignore recommendations for Craft 3? I'm especially wondering about craft/storage/userphotos
and craft/storage/logo
https://craftcms.com/support/craft-storage-gitignore recommends ignoring craft/storage/backups/
, craft/storage/runtime/
, and craft/storage/userphotos/
, and keeping craft/storage/rebrand/
— so,
/craft/storage/*
!/craft/storage/rebrand
But the latest craft/storage/.gitignore
has
backups
logs
runtime
which keeps craft/storage/userphotos
.
Meanwhile various sources (notably https://github.com/github/gitignore/blob/master/CraftCMS.gitignore, citing what I guess must be an old version of the documentation linked above) recommend keeping craft/storage/logo
and ignoring craft/storage/rebrand
with
/craft/storage/*
!/craft/storage/logo/*
Site-switcher doesn't switch for Globals in 4.5.X
There are dead links in the main README.md
for:
See the Craft 3 documentation for installation and updating instructions.
Originally posted by @Ealwora in craftcms/google-cloud#22 (comment)
After open some in admin area
Invalid Configuration – yii\base\InvalidConfigException
Unsupported DB driver value:
would be awesome to get a demo using/demonstrating the 3.0 features / best practices
I'd like to suggest the following change for the default general.php
file that ships with Craft CMS:
// Production environment settings
'production' => [
// Set this to `false` to prevent administrative changes from being made on production
'allowAdminChanges' => true,
]
return [
'production' => [
'devMode' => false,
'allowAdminChanges' => false,
'allowUpdates' => false,
],
]
The suggested change is making sure that best practices are set by default.
The Craft documentation states:
Disable the
allowAdminChanges
config setting on all non-development environments, to avoid losing changes unexpectedly going forward.
As far as I understand devMode
, this should also be set to false in production, as it might leak information on the system outside, like printing debugging information instead of a nicely designed error.
Last not least, I think the same applies for the updates. To make sure updates work as expected and that the local environment is sync with production, updates should best first be run locally. And for sure by a developer and not the client (I know there are permissions as well but better make sure).
I don't know. I tried to think about some cases … I can imagine that maybe less experienced developers who do not have an advanced setup including multiple environments could potentially get locked out of getting updates. But having multiple environments is optional. It's not required to set up something for production. It's just when there is something like production, let's set some good defaults right away.
Shameless plug: We at fortrabbit pre-populate ENVIRONMENT=production
with the ENV vars on our Apps. Now having "better" (<- our opinion) defaults would help us with some issues we are facing in support. Not all clients are following our guides and so they end up making different changes in productions and locally and that can turn into a hustle.
It would great if there are no changes that need to be made in general.php
for a good setup.
Related to issue #9
Craft version: 3.1.6.1
When you have one or more modules defined in config/app.php
, the ./craft
command throws an error:
Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @modules/controllers'
in .../vendor/yiisoft/yii2/BaseYii.php:154
It doesn't matter if the module has logic or not.
It's reproducable by just following the instructions to create a module.
https://docs.craftcms.com/v3/extend/module-guide.html#update-the-application-config
It would be nice if there was a note in the .env and config/general.php files that setting a security isn’t optional.
Hi there,
In this commit:
34e84a1
You have removed the var:
'securityKey' => App::env('CRAFT_SECURITY_KEY'),
And I can't find any documentation to explain why this change has been made. I understand that you've renamed all the .env vars that are created to have a CRAFT_ prefix, but where is the security key now referenced? Is it just an assumed global type thing?
Servd (the hosting company) currently inject a SECURITY_KEY
variable into a dynamic .env file, so I've let them know it should have a CRAFT_
prefix, as I was getting this deprecation warning on their servers:
"The auto-generated validation key stored at /var/www/html/storage/runtime/validation.key has been deprecated. Copy its value to the securityKey config setting in config/general.php."
According to More Information than You Require About Craft License Keys:
Don’t give anyone access to the license.key file that you don’t trust or owe money to! Remember that everyone that has access to the license key can easily transfer it to a new domain.
That being the case, what's the best practices in terms of checking license.key
into your git repository?
Obviously public would be a bad idea, but private seems on par with checking in your passwords or access tokens?
The .gitignore
file for this starter repo doesn't specifically exclude license.key
so I figured I'd ask...
Running the latest 3.0.0-RC16.1
Originally I had another site' license implemented on a new site. I then wiped it out to get rid of the persistent warning. Since then my client purchased the license on staging. But now I'm getting You’re running Craft Pro with a Craft Personal license. Resolve
. Upon clicking resolve the license warning goes away only to keep coming back at random times. I click Resolve then it show Pro has been purchased and Installed.
What can be done to resolve this?
I'm running into an issue where neo fields don't seem to populate while trying to run through Codeception. I've dug into this but haven't nailed down the exact issue; any ideas or help would be most appreciated.
There's an example repo you should be able to use to replicate the issue here: https://github.com/khamer/craftdemo-custom-fields-with-codeception
You should be able to configure that to run locally based on your development environments. If all is well, you should be able to run the codeception functional test ExampleCest and see "Test redactor in matrix" work but "Test redactor in neo" fail.
Having dug into this for a while, I believe the value isn't even being populated into the Entry even before it's saved. I think that's happening because it looks like for that to work, the generated tests/craft/storage/runtime/compiled_classes/CustomFieldBehavior***********.php file would need to have a reference to the relevant neo field - in this case, neoContent - but I only see bodyContent in the generated file. I think at the time of generating this file, for whatever reason the neo fields aren't within the fields table yet; and that's as far I've gotten.
It doesn't seem to be an issue for Matrix fields or the craftcms/redactor plugin's fields. I'll ask the spicyweb guys too, but I'd love to get this solved because this blocks us being able to do automated testing on sites using Neo, and I'm not sure if they're using Neo with codeception anywhere yet.
It's pretty common to have a setup like Docker which will inject environment variables into the containers... with Craft's default craftcms/craft
boilerplate, the phpdotenv package is called thusly:
// Load dotenv?
if (class_exists('Dotenv\Dotenv')) {
Dotenv\Dotenv::createUnsafeImmutable(CRAFT_BASE_PATH)->safeLoad();
}
Unfortunately, this means if I want to edit an .env
variable at runtime to test something, I need to spin the containers down, and then restart them, because createUnsafeImmutable()
causes it to be unable to overwrite existing environment variables
I may be missing a use-case, but I'd think it'd be pretty common/desirable that what is in your .env
can override environment variables that are already injected. The proposed change would be:
// Load dotenv?
if (class_exists('Dotenv\Dotenv')) {
Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}
The default, btw, if you use ::create()
is to use the mutable method... which makes me think there might be a specific reason why immutable was used?
I didn't create a PR, because it's relatively trivial, and also I'm guessing there are strong opinions backing up the current way of doing it?
.env
fileNow Craft 3.1 is out, please add the config-backups
folder to the .gitignore
file in the storage
directory.
I have an entry type where the title field is set to the value of the copy field ({copy}
). When I try to save an entry that has quite a bit of copy text, Craft will just get back to me with a general error "Couldn’t save entry", but without any hint why.
It’s an easy fix by having {copy|slice(0,20)}
as the title value, but I’d expect Craft to give me a more informative message like "title is too long" or something alike.
Craft 3 RC3
On upgrading from Craft 3.4 to 3.5 I've got many folders and yaml's (alongside the craft/config/project/project.yaml).
Can they be put to .gitignore or what are the recommendations for updating .gitignore on upgrade?
(F.ex. I manually upgraded the craft/storage .gitignore file on the 3.5 upgrade.)
On saving an edited asset (admin/actions/assets/save-image), I get a 500 error, with the following message:
Call to undefined method Imagine\Gd\Image::getImagick()
If you implement a module as per the example:
// All environments
'*' => [
'modules' => [
'my-module' => modules\Module::class,
],
'bootstrap' => ['my-module'],
],
This will cause the Yii Debug toolbar to no longer load, presumably because the 'bootstrap'
gets stomped on.
When using a custom cpTrigger path and having the CMS in headless mode the cpTrigger path returns a 404. It does not redirect to /login or /dashboard like it did previously.
Hey folks, I don't know if this belongs here or in the cms
repo, but here's an FR for the command line installer:
Could it be possible to create defaults for Site Name and Site URL based on the existence of those settings in the .env
file? Just like the Database seems to pull from the DB settings in .env
, it would be great to be able to bypass those by having {siteName}
and {siteUrl}
populated by default.
Even better, for the sake of easier automation, it would be great to be able to run ./craft setup
with all of the questions answered through command line arguments. For example, you could run ./craft setup --site_url="{siteUrl}" --site_name="{siteName}" etc...
to bypass all of the questions altogether.
I know that main project directory should not be avaible to apache, but sometimes for whatever reason we cannot avoid it.
On a fresh install of Craft, I'm getting a 404 error trying to load install-bg-1920.png
on the default index page. I see a file installer-bg.png
in my cpresources directory, so perhaps just a file name didn't get updated from "install" to "installer"?
The comment in general.php
is misleading.
Line 20 in 7460a38
Setting true does not show index.php
, but hide it.
Please change to this, like used in the source code:
// Whether generated URLs should omit "index.php"
When trying to use the ./craft
command I get the this error on a freshly installed RC1 system.
Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @modules/controllers'
in /home/user/source/vendor/yiisoft/yii2/BaseYii.php:154
Stack trace:
#0 /home/user/source/vendor/yiisoft/yii2/base/Module.php(257): yii\BaseYii::getAlias('@modules/contro...')
#1 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(250): yii\base\Module->getControllerPath()
#2 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(245): yii\console\controllers\HelpController->getModuleCommands(Object(modules\Module))
#3 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(179): yii\console\controllers\HelpController->getModuleCommands(Object(craft\console\Application))
#4 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(191): yii\console\controllers\HelpController->getCommands()
#5 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(286): yii\console\controllers\HelpController->getCommandDescriptions()
#6 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(67): yii\console\controllers\HelpController->getDefaultHelp()
#7 [internal function]: yii\console\controllers\HelpController->actionIndex(NULL)
#8 /home/user/source/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /home/user/source/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /home/user/source/vendor/yiisoft/yii2/console/Controller.php(135): yii\base\Controller->runAction('', Array)
#11 /home/user/source/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /home/user/source/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('', Array)
#13 /home/user/source/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('', Array)
#14 /home/user/source/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#15 /home/user/source/craft(22): yii\base\Application->run()
#16 {main}
If i return an empty array in config/app.php
instead of the default it seems to work
return [];
Instead of:
return [
'modules' => [
'my-module' => \modules\Module::class,
],
//'bootstrap' => ['my-module'],
];
On one of the servers i installed Craft, subpages didnt opened (only index.php) unless I added RewriteBase /
to .htaccess file.
Maybe this should be added to default Craft .htaccess file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.