Skip to content

Commit 04a40f5

Browse files
committed
Update
- Now support the laravel 8 and above - Readme file updated
1 parent 197e5b5 commit 04a40f5

22 files changed

+981
-169
lines changed

.php-cs-fixer.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"8.1.0","version":"3.8.0:v3.8.0#cbad1115aac4b5c3c5540e7210d3c9fba2f81fa3","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true},"hashes":{"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder1138\\src\\Textract.php":594584308,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder4653\\src\\Textract.php":594584308,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder4449\\src\\Textract.php":1716975831,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder664\\src\\Textract.php":1716975831,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder6129\\src\\Concerns\\MustHaveResponse.php":576381187,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder1273\\src\\Providers\\ServiceProvider.php":1788587239,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder6453\\src\\Providers\\ServiceProvider.php":1788587239,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder6236\\src\\Textract.php":1716975831,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder2086\\src\\Textract.php":1716975831,"C:\\Users\\nilge\\AppData\\Local\\Temp\\PHP CS Fixertemp_folder7027\\src\\Services\\ConsoleExtractionService.php":630574137}}

README.md

Lines changed: 68 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,76 @@
1+
[![Packagist](https://img.shields.io/packagist/v/nilgems/laravel-textract)](https://packagist.org/packages/nilgems/laravel-textract)
12
# Laravel Textract
2-
A [Laravel 9](https://laravel.com/docs/9.x/) package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring ["npm textract"](https://www.npmjs.com/package/textract).
3+
A [Laravel](https://laravel.com) package to extract text from files like DOC, Excel, Image, Pdf and more.
34

4-
[![PHP Version](https://img.shields.io/packagist/php-v/NilGems/laravel-textract)](https://www.php.net/downloads)
5-
[![Language Used](https://img.shields.io/github/languages/count/NilGems/laravel-textract)](https://github.com/NilGems/laravel-textract/search?l=php)
6-
[![Packagist](https://img.shields.io/packagist/v/nilgems/laravel-textract)](https://packagist.org/packages/nilgems/laravel-textract)
5+
# Versions and compatibility
76

7+
- [Laravel 8](https://laravel.com) or higher is required.
8+
- [Php 7.4]() or higher is required
9+
10+
### <img src="./blobs/danger.png?raw=true" alt="Note" width="18"> [Laravel 9](https://laravel.com) support is added.
811

912
### Supported file formats
1013
Following file formats is supported currently. You need to install proper extensions
1114
to your server to work with all the following extension related files. The package will
12-
check file content MIME type before execute. So with the extension you have maintain
13-
the current content type to work this package-
14-
- HTML
15-
- TEXT
16-
- DOC
17-
- DOCX
18-
- XLS, XLSX, XLSM, XLTX, XLTM, XLT
19-
- CSV
20-
- PDF
21-
- Image
22-
- Jpeg
23-
- Pdf
24-
- ODT
25-
- ODS
26-
- RTF
27-
28-
### Install
15+
check file content MIME type before execute.
16+
- **HTML**
17+
- **TEXT**
18+
- **DOC**
19+
- **DOCX**
20+
- **XLS**, **XLSX**, **XLSM**, **XLTX**, **XLTM**, **XLT**
21+
- **CSV**
22+
- **PDF**
23+
- **Image**
24+
- _jpeg_
25+
- _png_
26+
- **ODT**
27+
- **ODS**
28+
- **RTF**
29+
30+
<img src="./blobs/warning.png?raw=true" alt="Note" width="12">***GIF*** and ***PPT*** support is under development.
31+
32+
**We are working hard to make this laravel plugin useful. If you found any issue please add a post on discussion.**
33+
34+
### Installation
35+
2936
```
3037
composer require nilgems/laravel-textract
3138
```
39+
Once installed you can do stuff like this:
40+
```
41+
# Run the extractor
42+
$output = Textract::run('/path/to/file.extension');
43+
44+
# Display the extracted text
45+
echo $output->text;
46+
47+
# Display the extracted text word count
48+
echo $output->word_count;
49+
50+
# Display the extracted text with direct string conversion
51+
echo (string) $output;
52+
```
53+
3254
### Configuration
33-
You don't need to anything special for your laravel application to work with this
34-
package.
55+
56+
- You can add **provider** in ```app.php``` under the ```config``` folder of your
57+
[Laravel](https://laravel.com) project. It's optional, the package automatically load the service provider in your application.
58+
```
59+
'providers' => [
60+
...
61+
Nilgems\PhpTextract\Providers\ServiceProvider,
62+
...
63+
]
64+
```
65+
- Add **alias** in ```app.php``` under the ```config``` folder of your
66+
[Laravel](https://laravel.com) project. It's optional, the package automatically load the ```facade``` in your application.
67+
```
68+
'aliases' => [
69+
...
70+
'Textract' => Nilgems\PhpTextract\Textract::class,
71+
...
72+
]
73+
```
3574
### Example
3675
Use the ```Nilge\Textract\Textract``` facade to run the extractor.
3776
```
@@ -47,8 +86,7 @@ In ```php``` there have a restriction of execution time and memory limit defined
4786
use Nilge\Textract\Textract;
4887
4988
Route::get('/textract', function(){
50-
$file_path = ...;
51-
return Textract::run($file_path);
89+
return Textract::run('/path/to/image/example.png');
5290
});
5391
........
5492
```
@@ -60,8 +98,7 @@ If you need to specify languages in image file for better extraction output from
6098
use Nilge\Textract\Textract;
6199
62100
Route::get('/textract', function(){
63-
$image_file_path = ...;
64-
return Textract::run($file_path, null, [
101+
return Textract::run('/path/to/image/example.png', null, [
65102
'lang' => ['eng', 'jpn', 'spa']
66103
]);
67104
});
@@ -71,10 +108,10 @@ Route::get('/textract', function(){
71108
- To enable the image extraction feature you need to install [Tesseract OCR](https://github.com/tesseract-ocr/tesseract)
72109
- To enable the PDF extraction feature you need to install [pdftotext](http://www.xpdfreader.com/download.html)
73110
- To work properly, your server must have following php extensions installed -
74-
- ext-fileinfo
75-
- ext-zip
76-
- ext-gd or ext-imagick
77-
- ext-xml
111+
- **ext-fileinfo**
112+
- **ext-zip**
113+
- **ext-gd** or **ext-imagick**
114+
- **ext-xml**
78115
### Tesseract OCR Installation
79116
#### <img src="https://raw.githubusercontent.com/NilGems/laravel-textract/master/blobs/ubuntu.png" width="12" alt="Ubuntu" /> Ubuntu
80117
- Update the system: ```sudo apt update```
@@ -103,9 +140,6 @@ Route::get('/textract', function(){
103140
---
104141
## 💻 Tech Stack
105142
![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=plastic&logo=css3&logoColor=white) ![PHP](https://img.shields.io/badge/php-%23777BB4.svg?style=plastic&logo=php&logoColor=white) ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=plastic&logo=html5&logoColor=white) ![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=plastic&logo=javascript&logoColor=%23F7DF1E) ![AWS](https://img.shields.io/badge/AWS-%23FF9900.svg?style=plastic&logo=amazon-aws&logoColor=white) ![Vue.js](https://img.shields.io/badge/vuejs-%2335495e.svg?style=plastic&logo=vuedotjs&logoColor=%234FC08D) ![Vuetify](https://img.shields.io/badge/Vuetify-1867C0?style=plastic&logo=vuetify&logoColor=AEDDFF) ![NPM](https://img.shields.io/badge/NPM-%23000000.svg?style=plastic&logo=npm&logoColor=white) ![jQuery](https://img.shields.io/badge/jquery-%230769AD.svg?style=plastic&logo=jquery&logoColor=white) ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=plastic&logo=express&logoColor=%2361DAFB) ![Laravel](https://img.shields.io/badge/laravel-%23FF2D20.svg?style=plastic&logo=laravel&logoColor=white) ![NuxtJS](https://img.shields.io/badge/Nuxt-black?style=plastic&logo=nuxt.js&logoColor=white) ![Socket.io](https://img.shields.io/badge/Socket.io-black?style=plastic&logo=socket.io&badgeColor=010101) ![Apache](https://img.shields.io/badge/apache-%23D42029.svg?style=plastic&logo=apache&logoColor=white) ![MariaDB](https://img.shields.io/badge/MariaDB-003545?style=plastic&logo=mariadb&logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=plastic&logo=mongodb&logoColor=white) ![MySQL](https://img.shields.io/badge/mysql-%2300f.svg?style=plastic&logo=mysql&logoColor=white) ![SQLite](https://img.shields.io/badge/sqlite-%2307405e.svg?style=plastic&logo=sqlite&logoColor=white) ![Inkscape](https://img.shields.io/badge/Inkscape-e0e0e0?style=plastic&logo=inkscape&logoColor=080A13) ![Jira](https://img.shields.io/badge/jira-%230A0FFF.svg?style=plastic&logo=jira&logoColor=white) ![Vagrant](https://img.shields.io/badge/vagrant-%231563FF.svg?style=plastic&logo=vagrant&logoColor=white)
106-
## 📊 GitHub Stats :
107-
![](https://github-readme-stats.vercel.app/api?username=NilGems&theme=radical&hide_border=false&include_all_commits=false&count_private=false)<br/>
108-
![](https://github-readme-stats.vercel.app/api/top-langs/?username=NilGems&theme=radical&hide_border=false&include_all_commits=false&count_private=false&layout=compact)
109143

110144
---
111145
[![](https://visitcount.itsvg.in/api?id=NilGems&icon=0&color=0)](https://visitcount.itsvg.in)

blobs/danger.png

2.47 KB
Loading

blobs/sticky-notes.png

6.59 KB
Loading

blobs/warning.png

3.43 KB
Loading

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737
"symfony/process": "^6.1",
3838
"phpoffice/phpspreadsheet": "^1.23",
3939
"phpoffice/phpword": "^0.18",
40-
"laravel/framework": "^8.0|^9.0"
40+
"laravel/framework": "^8.0|^9.0",
41+
"thiagoalessio/tesseract_ocr": "^2.12",
42+
"stechstudio/laravel-php-cs-fixer": "^3.1"
4143
},
4244
"require-dev": {
43-
"squizlabs/php_codesniffer": "^3.6"
45+
"friendsofphp/php-cs-fixer": "^v3.8.0"
4446
},
4547
"license": "MIT",
4648
"autoload": {

0 commit comments

Comments
 (0)