<p>This is not really specific to Craft, but you should import <code>Craft</code> at the beginning of your class file like this:</p>

<pre class="lang-php prettyprint-override"><code>&lt;?php

use Craft;

...
</code></pre>

<p>I suggest you take a look at that documentation for more details about how to import PHP classes: <a href="https://www.php.net/manual/en/language.namespaces.importing.php" rel="nofollow noreferrer">https://www.php.net/manual/en/language.namespaces.importing.php</a></p>

CC BY-SA 4.0
2019-07-09T18:11:12.687Z
use Craft; gave the following error:
Warning: The use statement with non-compound name 'Craft' has no effect
Amir
CC BY-SA 4.0
2019-07-11T11:44:54.877Z
In what context are you using the Craft object? Are you using a Module ou a Plugin? If not, you should include the Framework autoloader from the `vendors` folder in order to use its classes. You will find an example of how to do that by looking to the `index.php` file in the `web` folder of your project. However, in your use case, using a Module looks like the way to go.
Alban Jubert
CC BY-SA 4.0
2019-07-05T12:35:46.597Z
2019-07-05T12:35:46.597Z
Alban Jubert
<p>I am new to PHP and trying to call reCaptcha API in CraftCMS. I have the following variable: </p>

<pre><code>$captcha = Craft::$app-&gt;getRequest()-&gt;getParam('g-recaptcha-response');
</code></pre>

<p>But I get the following error when I submit a form: </p>

<pre><code>Fatal error: Uncaught Error: Class 'Craft' not found
</code></pre>

<p>How can I import the Craft class? </p>

<error-message><classes><plugin-recaptcha>
Class 'Craft' not found
# Class 'Craft' not found

(Asked by: username_0 on 2019-07-04)

I am new to PHP and trying to call reCaptcha API in CraftCMS. I have the following variable: 
$captcha = Craft::$app->getRequest()->getParam('g-recaptcha-response');

But I get the following error when I submit a form: 
Fatal error: Uncaught Error: Class 'Craft' not found

How can I import the Craft class?

**Tags:** error-message, classes, plugin-recaptcha

---

## 1 answers

### Answer by username_1 on 2019-07-05. Score: 1

This is not really specific to Craft, but you should import Craft at the beginning of your class file like this:

I suggest you take a look at that documentation for more details about how to import PHP classes: https://www.php.net/manual/en/language.namespaces.importing.php

> **Comments:**
> **username_0**: use Craft; gave the following error: Warning: The use statement with non-compound name 'Craft' has no effect  
> **username_1**: In what context are you using the Craft object? Are you using a Module ou a Plugin? If not, you should include the Framework autoloader from the `vendors` folder in order to use its classes. You will find an example of how to do that by looking to the `index.php` file in the `web` folder of your project. However, in your use case, using a Module looks like the way to go.  

---

